Skip to content

Commit

Permalink
Update/prepare schema-dts & -gen v1.1.2 (#188)
Browse files Browse the repository at this point in the history
- Updates dependencies
- Use all layers instead of current layers (this was a regression from
   moving to new Schema.org URLs for their schemas.
- New schema-dts push for v15
  • Loading branch information
Eyas authored Feb 24, 2023
1 parent 6470181 commit f83949b
Show file tree
Hide file tree
Showing 73 changed files with 3,168 additions and 8,887 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ module.exports = {
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: ['typeProperty', 'objectLiteralProperty'],
format: null,
},
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
Expand Down
9,559 changes: 1,927 additions & 7,632 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
"Eyas Sharaiha <npm@eyas.sh> (https://eyas.sh/)"
],
"devDependencies": {
"@jest/globals": "^27.5.1",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.4.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsdoc": "^37.9.4",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.3",
"typescript": "^4.3.2"
"@jest/globals": "^29.4.3",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^40.0.0",
"jest": "^29.4.3",
"prettier": "^2.8.4",
"rimraf": "^4.1.2",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
},
"engines": {
"node": ">=14.0.0",
Expand Down
5 changes: 0 additions & 5 deletions packages/schema-dts-gen/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
export default {
preset: 'ts-jest/presets/default-esm', // or other ESM presets
globals: {
'ts-jest': {
useESM: true,
},
},
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
Expand Down
17 changes: 8 additions & 9 deletions packages/schema-dts-gen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "schema-dts-gen",
"version": "1.1.0",
"version": "1.1.2",
"displayName": "schema-dts Generator",
"description": "Generate TypeScript Definitions for Schema.org Schema",
"author": "Eyas Sharaiha <eyas@google.com> (https://eyas.sh/)",
Expand All @@ -21,33 +21,33 @@
"sideEffects": false,
"type": "module",
"devDependencies": {
"@jest/globals": "^27.5.1",
"@jest/globals": "^29.4.3",
"@types/argparse": "^2.0.10",
"@types/array.prototype.flatmap": "^1.2.2",
"@types/diff": "^5.0.2",
"@types/jest": "^27.4.1",
"@types/jest": "^29.4.0",
"@types/n3": "^1.10.4",
"@types/node": "^17.0.21",
"@types/node": "^18.14.1",
"@types/unist": "^2.0.6",
"cross-env": "^7.0.3"
},
"dependencies": {
"argparse": "^2.0.1",
"n3": "^1.13.0",
"rehype-minify-whitespace": "^5.0.0",
"n3": "^1.16.3",
"rehype-minify-whitespace": "^5.0.1",
"rehype-parse": "^8.0.4",
"rehype-raw": "^6.1.1",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"remark-wiki-link": "^1.0.4",
"unified": "^10.1.1"
"unified": "^10.1.2"
},
"engines": {
"node": ">=14.0.0"
},
"engineStrict": true,
"peerDependencies": {
"typescript": ">=4.1.0"
"typescript": ">=4.9.5"
},
"nyc": {
"extension": [
Expand Down Expand Up @@ -91,7 +91,6 @@
"scripts": {
"lint:eslint": "eslint src/**/*.ts test/**/*.ts",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"prepare": "npm run build",
"build": "tsc -b"
}
}
4 changes: 2 additions & 2 deletions packages/schema-dts-gen/src/cli/args.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,7 +70,7 @@ export function ParseFlags(args?: string[]): Options {
dest: 'context',
});
parser.add_argument('--ontology', {
default: 'https://schema.org/version/latest/schemaorg-current-https.nt',
default: 'https://schema.org/version/latest/schemaorg-all-https.nt',
help:
'HTTPS URL to a custom .nt file defining an entirely self-' +
'sufficient schema. The schema must still be described in terms of ' +
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/cli/internal/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/logging/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/transform/toClass.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/transform/toEnum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/transform/toProperty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/transform/transform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/triples/operators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/triples/reader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/triples/term_utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/triples/wellKnown.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
15 changes: 8 additions & 7 deletions packages/schema-dts-gen/src/ts/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -273,7 +273,6 @@ export class Class {
.map(prop => prop.toNode(context, properties));

return factory.createInterfaceDeclaration(
/*decorators=*/ [],
/*modifiers=*/ [],
baseName,
/*typeParameters=*/ [],
Expand All @@ -294,7 +293,6 @@ export class Class {
assert(baseName, 'Expect baseName to exist when leafName exists.');

return factory.createInterfaceDeclaration(
/*decorators=*/ [],
/*modifiers=*/ [],
leafName,
/*typeParameters=*/ [],
Expand Down Expand Up @@ -366,7 +364,6 @@ export class Class {
const declaration = withComments(
this.comment,
factory.createTypeAliasDeclaration(
/* decorators = */ [],
factory.createModifiersFromModifierFlags(ModifierFlags.Export),
this.className(),
this.typeParameters(),
Expand Down Expand Up @@ -440,11 +437,13 @@ export class RoleBuiltin extends Builtin {
protected typeParameters(): readonly TypeParameterDeclaration[] {
return [
factory.createTypeParameterDeclaration(
/*modifiers=*/ [],
/*name=*/ RoleBuiltin.kContentTypename,
/*constraint=*/ undefined,
/*default=*/ factory.createTypeReferenceNode('never')
),
factory.createTypeParameterDeclaration(
/*modifiers=*/ [],
/*name=*/ RoleBuiltin.kPropertyTypename,
/*constraint=*/ factory.createTypeReferenceNode('string'),
/*default=*/ factory.createTypeReferenceNode('never')
Expand Down Expand Up @@ -489,15 +488,16 @@ export class RoleBuiltin extends Builtin {
assert(baseName, 'Role must have Base Name.');

return factory.createTypeAliasDeclaration(
/*decorators=*/ [],
/*modifiers=*/ [],
leafName,
/*typeParameters=*/ [
factory.createTypeParameterDeclaration(
/*modifiers=*/ [],
/*name=*/ RoleBuiltin.kContentTypename,
/*constraint=*/ undefined
),
factory.createTypeParameterDeclaration(
/*modifiers=*/ [],
/*name=*/ RoleBuiltin.kPropertyTypename,
/*constraint=*/ factory.createTypeReferenceNode('string')
),
Expand All @@ -511,6 +511,7 @@ export class RoleBuiltin extends Builtin {
factory.createMappedTypeNode(
/*initialToken=*/ undefined,
/*typeParameter=*/ factory.createTypeParameterDeclaration(
/*modifiers=*/ [],
'key',
/*constraint=*/ factory.createTypeReferenceNode(
RoleBuiltin.kPropertyTypename
Expand All @@ -520,7 +521,8 @@ export class RoleBuiltin extends Builtin {
/*questionToken=*/ undefined,
/*type=*/ factory.createTypeReferenceNode(
RoleBuiltin.kContentTypename
)
),
/*members=*/ undefined
),
])
);
Expand All @@ -539,7 +541,6 @@ export class DataTypeUnion extends Builtin {
withComments(
this.comment,
factory.createTypeAliasDeclaration(
/*decorators=*/ [],
factory.createModifiersFromModifierFlags(ModifierFlags.Export),
namedPortion(this.subject),
/*typeParameters=*/ [],
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/ts/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/ts/enum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
8 changes: 3 additions & 5 deletions packages/schema-dts-gen/src/ts/helper_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ function WithContextType(context: Context) {
'objects used. The context provided in this type is compatible ' +
'with the keys and URLs in the rest of this generated file.',
factory.createTypeAliasDeclaration(
/*decorators=*/ [],
factory.createModifiersFromModifierFlags(ModifierFlags.Export),
'WithContext',
[
factory.createTypeParameterDeclaration(
/*modifiers=*/ [],
'T' /*constraint=*/,
factory.createTypeReferenceNode('Thing', /*typeArguments=*/ undefined)
),
Expand All @@ -49,7 +49,6 @@ function GraphType(context: Context) {
return withComments(
'',
factory.createInterfaceDeclaration(
/*decorators=*/ [],
factory.createModifiersFromModifierFlags(ModifierFlags.Export),
GraphTypeName,
/*typeParameters=*/ undefined,
Expand Down Expand Up @@ -99,13 +98,13 @@ export function HelperTypes(context: Context, {hasRole}: {hasRole: boolean}) {
WithContextType(context),
GraphType(context),
factory.createTypeAliasDeclaration(
/*decorators=*/ [],
/*modifiers=*/ [],
SchemaValueName,
arrayOf(
factory.createTypeParameterDeclaration('T'),
factory.createTypeParameterDeclaration(/*modifiers=*/ [], 'T'),
hasRole &&
factory.createTypeParameterDeclaration(
/*modifiers=*/ [],
'TProperty',
/*constraint=*/ factory.createTypeReferenceNode('string')
)
Expand Down Expand Up @@ -135,7 +134,6 @@ export function HelperTypes(context: Context, {hasRole}: {hasRole: boolean}) {
)
),
factory.createTypeAliasDeclaration(
/*decorators=*/ [],
/*modifiers=*/ [],
IdReferenceName,
/*typeParameters=*/ [],
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/ts/property.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/ts/util/arrayof.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/ts/util/comments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/ts/util/names.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/ts/util/union.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-dts-gen/src/util/assert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit f83949b

Please sign in to comment.