Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dts-gen): Characters check for typename compliant with ECMA262. #3042

Merged

Conversation

tuchida
Copy link
Contributor

@tuchida tuchida commented Oct 29, 2024

ref. #3035

Why

Supported to use Japanese in version 5, but error in version 8.

# success
$ npx -p @kintone/dts-gen@5 kintone-dts-gen --app-id 12 --type-name 'App取引先Fields'
$ npx -p @kintone/dts-gen@8 kintone-dts-gen --app-id 12 --type-name 'App取引先Fields'
Invalid type-name option!
The namespace and type-name convention:
- Starts with a letter (`a-z` or `A-Z`), underscore (`_`), or dollar sign (`$`).
- Can be followed by any alphanumeric, underscores, or dollar signs.

What

This pull request will enable the use of Japanese in typename.

How to test

Look at diff in args.test.ts.

Checklist

  • Read CONTRIBUTING.md
  • Updated documentation if it is required.
  • Added tests if it is required.
  • Passed pnpm lint and pnpm test on the root directory.

@tuchida tuchida requested a review from a team as a code owner October 29, 2024 08:02
@tuchida tuchida requested review from chihiro-adachi and tasshi-me and removed request for a team October 29, 2024 08:02
@github-actions github-actions bot added the pkg: dts-gen @kintone/dts-gen label Oct 29, 2024
* @param targetIdentifier
*/
const isValidIdentifier = (targetIdentifier: string): boolean => {
const identifiers = targetIdentifier.split(".");
const identifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
const identifierRegex = /^[\p{ID_Start}_$][\p{ID_Continue}$\u200C\u200D]*$/u;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unicode character class escape may not be converted by a transpiler such as Babel.

@tuchida tuchida changed the title fix #3035 Characters check for typename compliant with ECMA262. feat(dts-gen): Characters check for typename compliant with ECMA262. Oct 29, 2024
@chihiro-adachi
Copy link
Contributor

@tuchida
Thank you! I'll check it!

@chihiro-adachi
Copy link
Contributor

日本語で生成されることを確認

$ node dist/index.js --app-id 1 --type-name 'App取引先Fields' --base-url=http://localhost --username=username --password=password

$ cat fields.d.ts
declare namespace kintone.types {
  interface App取引先Fields {
    文字列__1行_: kintone.fieldTypes.SingleLineText;

    添付ファイル: kintone.fieldTypes.File;
  }
  interface SavedApp取引先Fields extends App取引先Fields {
    $id: kintone.fieldTypes.Id;
    $revision: kintone.fieldTypes.Revision;
    更新者: kintone.fieldTypes.Modifier;
    作成者: kintone.fieldTypes.Creator;
    レコード番号: kintone.fieldTypes.RecordNumber;
    更新日時: kintone.fieldTypes.UpdatedTime;
    作成日時: kintone.fieldTypes.CreatedTime;
  }
}

Copy link
Member

@shabaraba shabaraba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chihiro-adachi chihiro-adachi merged commit fefe7c9 into kintone:main Nov 4, 2024
18 of 19 checks passed
@chihiro-adachi
Copy link
Contributor

@tuchida
Thank you! merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: dts-gen @kintone/dts-gen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants