@feathersjs/generators 5.0.0-pre.36 → 5.0.0-pre.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +0 -1
  3. package/lib/app/index.d.ts +38 -5
  4. package/lib/app/index.js +11 -21
  5. package/lib/app/index.js.map +1 -1
  6. package/lib/app/index.ts +18 -41
  7. package/lib/app/templates/app.tpl.js +10 -9
  8. package/lib/app/templates/app.tpl.js.map +1 -1
  9. package/lib/app/templates/app.tpl.ts +12 -9
  10. package/lib/app/templates/channels.tpl.js +1 -6
  11. package/lib/app/templates/channels.tpl.js.map +1 -1
  12. package/lib/app/templates/channels.tpl.ts +7 -9
  13. package/lib/app/templates/client.test.tpl.js +1 -1
  14. package/lib/app/templates/client.test.tpl.js.map +1 -1
  15. package/lib/app/templates/client.test.tpl.ts +4 -2
  16. package/lib/app/templates/client.tpl.js +1 -1
  17. package/lib/app/templates/client.tpl.js.map +1 -1
  18. package/lib/app/templates/client.tpl.ts +7 -4
  19. package/lib/app/templates/configuration.tpl.js +8 -4
  20. package/lib/app/templates/configuration.tpl.js.map +1 -1
  21. package/lib/app/templates/configuration.tpl.ts +15 -8
  22. package/lib/app/templates/declarations.tpl.js +4 -2
  23. package/lib/app/templates/declarations.tpl.js.map +1 -1
  24. package/lib/app/templates/declarations.tpl.ts +7 -2
  25. package/lib/app/templates/package.json.tpl.js +9 -3
  26. package/lib/app/templates/package.json.tpl.js.map +1 -1
  27. package/lib/app/templates/package.json.tpl.ts +9 -2
  28. package/lib/authentication/index.d.ts +3 -38
  29. package/lib/authentication/index.js +8 -23
  30. package/lib/authentication/index.js.map +1 -1
  31. package/lib/authentication/index.ts +58 -75
  32. package/lib/authentication/templates/authentication.tpl.js +4 -4
  33. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  34. package/lib/authentication/templates/authentication.tpl.ts +2 -1
  35. package/lib/authentication/templates/client.test.tpl.js +5 -5
  36. package/lib/authentication/templates/client.test.tpl.js.map +1 -1
  37. package/lib/authentication/templates/client.test.tpl.ts +11 -7
  38. package/lib/commons.d.ts +24 -3
  39. package/lib/commons.js +33 -1
  40. package/lib/commons.js.map +1 -1
  41. package/lib/commons.ts +41 -3
  42. package/lib/connection/index.d.ts +3 -20
  43. package/lib/connection/index.js +13 -10
  44. package/lib/connection/index.js.map +1 -1
  45. package/lib/connection/index.ts +58 -50
  46. package/lib/connection/templates/knex.tpl.js +10 -1
  47. package/lib/connection/templates/knex.tpl.js.map +1 -1
  48. package/lib/connection/templates/knex.tpl.ts +6 -0
  49. package/lib/connection/templates/mongodb.tpl.js +15 -9
  50. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  51. package/lib/connection/templates/mongodb.tpl.ts +20 -10
  52. package/lib/service/index.d.ts +4 -0
  53. package/lib/service/index.js +82 -73
  54. package/lib/service/index.js.map +1 -1
  55. package/lib/service/index.ts +94 -74
  56. package/lib/service/templates/client.tpl.js +2 -3
  57. package/lib/service/templates/client.tpl.js.map +1 -1
  58. package/lib/service/templates/client.tpl.ts +14 -14
  59. package/lib/service/templates/schema.json.tpl.js +43 -17
  60. package/lib/service/templates/schema.json.tpl.js.map +1 -1
  61. package/lib/service/templates/schema.json.tpl.ts +57 -16
  62. package/lib/service/templates/schema.typebox.tpl.js +46 -11
  63. package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
  64. package/lib/service/templates/schema.typebox.tpl.ts +63 -11
  65. package/lib/service/templates/service.tpl.d.ts +1 -1
  66. package/lib/service/templates/service.tpl.js +6 -2
  67. package/lib/service/templates/service.tpl.js.map +1 -1
  68. package/lib/service/templates/service.tpl.ts +11 -2
  69. package/lib/service/templates/shared.tpl.js +2 -2
  70. package/lib/service/templates/shared.tpl.js.map +1 -1
  71. package/lib/service/templates/shared.tpl.ts +13 -10
  72. package/lib/service/type/custom.tpl.js +1 -1
  73. package/lib/service/type/custom.tpl.js.map +1 -1
  74. package/lib/service/type/custom.tpl.ts +1 -1
  75. package/lib/service/type/knex.tpl.js +14 -8
  76. package/lib/service/type/knex.tpl.js.map +1 -1
  77. package/lib/service/type/knex.tpl.ts +21 -10
  78. package/lib/service/type/mongodb.tpl.js +1 -1
  79. package/lib/service/type/mongodb.tpl.js.map +1 -1
  80. package/lib/service/type/mongodb.tpl.ts +1 -1
  81. package/package.json +29 -24
  82. package/lib/authentication/templates/knex.tpl.d.ts +0 -2
  83. package/lib/authentication/templates/knex.tpl.js +0 -45
  84. package/lib/authentication/templates/knex.tpl.js.map +0 -1
  85. package/lib/authentication/templates/knex.tpl.ts +0 -62
  86. package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
  87. package/lib/authentication/templates/schema.json.tpl.js +0 -104
  88. package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
  89. package/lib/authentication/templates/schema.json.tpl.ts +0 -125
  90. package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
  91. package/lib/authentication/templates/schema.typebox.tpl.js +0 -87
  92. package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
  93. package/lib/authentication/templates/schema.typebox.tpl.ts +0 -109
@@ -31,7 +31,7 @@ export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Que
31
31
 
32
32
  // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
33
33
  export class ${className}<ServiceParams extends Params = ${upperName}Params>
34
- extends MongoDBService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
34
+ extends MongoDBService<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
35
35
  }
36
36
 
37
37
  export const getOptions = (app: Application): MongoDBAdapterOptions => {
@@ -1 +1 @@
1
- {"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/service/type/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,MAAM,EACN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ACT,SAAS;CAEhB;;gBAEgB,SAAS,KAAK,SAAS,SAAS,SAAS,UAAU,SAAS;;mBAEzD,SAAS,uCAAuC,SAAS;;;;eAI7D,SAAS,mCAAmC,SAAS;2BACzC,SAAS,KAAK,SAAS,SAAS,SAAS,WAAW,SAAS;;;;;;gEAMxB,SAAS;;;CAGxE,CAAA;AA9CY,QAAA,QAAQ,YA8CpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
@@ -39,7 +39,7 @@ export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Que
39
39
 
40
40
  // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
41
41
  export class ${className}<ServiceParams extends Params = ${upperName}Params>
42
- extends MongoDBService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
42
+ extends MongoDBService<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
43
43
  }
44
44
 
45
45
  export const getOptions = (app: Application): MongoDBAdapterOptions => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feathersjs/generators",
3
- "version": "5.0.0-pre.36",
3
+ "version": "5.0.0-pre.38",
4
4
  "description": "Feathers CLI core generators, powered by Pinion",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "keywords": [
@@ -55,35 +55,40 @@
55
55
  "@feathershq/pinion": "^0.3.5",
56
56
  "chalk": "^4.0.1",
57
57
  "lodash": "^4.17.21",
58
- "prettier": "^2.8.3",
59
- "typescript": "^4.9.4"
58
+ "prettier": "^2.8.4",
59
+ "typescript": "^4.9.5"
60
60
  },
61
61
  "devDependencies": {
62
- "@feathersjs/adapter-commons": "^5.0.0-pre.36",
63
- "@feathersjs/authentication": "^5.0.0-pre.36",
64
- "@feathersjs/authentication-client": "^5.0.0-pre.36",
65
- "@feathersjs/authentication-local": "^5.0.0-pre.36",
66
- "@feathersjs/authentication-oauth": "^5.0.0-pre.36",
67
- "@feathersjs/configuration": "^5.0.0-pre.36",
68
- "@feathersjs/errors": "^5.0.0-pre.36",
69
- "@feathersjs/express": "^5.0.0-pre.36",
70
- "@feathersjs/feathers": "^5.0.0-pre.36",
71
- "@feathersjs/knex": "^5.0.0-pre.36",
72
- "@feathersjs/koa": "^5.0.0-pre.36",
73
- "@feathersjs/mongodb": "^5.0.0-pre.36",
74
- "@feathersjs/rest-client": "^5.0.0-pre.36",
75
- "@feathersjs/schema": "^5.0.0-pre.36",
76
- "@feathersjs/socketio": "^5.0.0-pre.36",
77
- "@feathersjs/transport-commons": "^5.0.0-pre.36",
78
- "@feathersjs/typebox": "^5.0.0-pre.36",
62
+ "@feathersjs/adapter-commons": "^5.0.0-pre.38",
63
+ "@feathersjs/authentication": "^5.0.0-pre.38",
64
+ "@feathersjs/authentication-client": "^5.0.0-pre.38",
65
+ "@feathersjs/authentication-local": "^5.0.0-pre.38",
66
+ "@feathersjs/authentication-oauth": "^5.0.0-pre.38",
67
+ "@feathersjs/configuration": "^5.0.0-pre.38",
68
+ "@feathersjs/errors": "^5.0.0-pre.38",
69
+ "@feathersjs/express": "^5.0.0-pre.38",
70
+ "@feathersjs/feathers": "^5.0.0-pre.38",
71
+ "@feathersjs/knex": "^5.0.0-pre.38",
72
+ "@feathersjs/koa": "^5.0.0-pre.38",
73
+ "@feathersjs/mongodb": "^5.0.0-pre.38",
74
+ "@feathersjs/rest-client": "^5.0.0-pre.38",
75
+ "@feathersjs/schema": "^5.0.0-pre.38",
76
+ "@feathersjs/socketio": "^5.0.0-pre.38",
77
+ "@feathersjs/transport-commons": "^5.0.0-pre.38",
78
+ "@feathersjs/typebox": "^5.0.0-pre.38",
79
79
  "@types/mocha": "^10.0.1",
80
- "@types/node": "^18.11.18",
80
+ "@types/node": "^18.13.0",
81
81
  "@types/prettier": "^2.7.2",
82
- "axios": "^1.2.6",
82
+ "axios": "^1.3.2",
83
83
  "mocha": "^10.2.0",
84
+ "mongodb": "^5.0.1",
85
+ "mssql": "^9.1.1",
86
+ "mysql": "^2.18.1",
87
+ "pg": "^8.9.0",
84
88
  "shx": "^0.3.4",
89
+ "sqlite3": "^5.1.4",
85
90
  "ts-node": "^10.9.1",
86
- "type-fest": "^3.5.3"
91
+ "type-fest": "^3.5.7"
87
92
  },
88
- "gitHead": "9a107b463cc80d7f3c28553c908987e05b0b634a"
93
+ "gitHead": "7fc86307438ae8cf3f71ce3b677be8bcc55768c1"
89
94
  }
@@ -1,2 +0,0 @@
1
- import { AuthenticationGeneratorContext } from '../index';
2
- export declare const generate: (ctx: AuthenticationGeneratorContext) => Promise<AuthenticationGeneratorContext>;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const migrationTemplate = ({ kebabPath, authStrategies }) => /* ts */ `import type { Knex } from 'knex'
7
-
8
- export async function up(knex: Knex): Promise<void> {
9
- await knex.schema.alterTable('${kebabPath}', function (table) {
10
- table.dropColumn('text')${authStrategies
11
- .map((name) => name === 'local'
12
- ? `
13
- table.string('email').unique()
14
- table.string('password')`
15
- : `
16
- table.string('${name}Id')`)
17
- .join('\n')}
18
- })
19
- }
20
-
21
- export async function down(knex: Knex): Promise<void> {
22
- await knex.schema.alterTable('${kebabPath}', function (table) {
23
- table.string('text')${authStrategies
24
- .map((name) => name === 'local'
25
- ? `
26
- table.dropColumn('email')
27
- table.dropColumn('password')`
28
- : `
29
- table.dropColumn('${name}Id')
30
- `)
31
- .join('\n')}
32
- })
33
- }
34
- `;
35
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)((ctx) => { var _a; return (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database) === 'knex'; }, (0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)((0, pinion_1.toFile)('migrations', () => {
36
- // Probably not great but it works to align with the Knex migration file format
37
- // We add a few seconds so that the migrations run in the correct order
38
- const migrationDate = new Date(Date.now() + 10000)
39
- .toISOString()
40
- .replace(/\D/g, '')
41
- .substring(0, 14);
42
- return `${migrationDate}_authentication`;
43
- })))));
44
- exports.generate = generate;
45
- //# sourceMappingURL=knex.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAgE;AAGhE,MAAM,iBAAiB,GAAG,CAAC,EACzB,SAAS,EACT,cAAc,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;kCAGb,SAAS;8BACb,cAAc;KACrC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;;6BAEiB;IACnB,CAAC,CAAC;oBACQ,IAAI,MAAM,CACvB;KACA,IAAI,CAAC,IAAI,CAAC;;;;;kCAKiB,SAAS;0BACjB,cAAc;KACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;;iCAEqB;IACvB,CAAC,CAAC;wBACY,IAAI;KACvB,CACE;KACA,IAAI,CAAC,IAAI,CAAC;;;CAGhB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,WAAC,OAAA,IAAA,4BAAkB,EAAC,MAAA,GAAG,CAAC,QAAQ,0CAAE,QAAQ,CAAC,KAAK,MAAM,CAAA,EAAA,EAC9D,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EACJ,IAAA,eAAM,EAAiC,YAAY,EAAE,GAAG,EAAE;IACxD,+EAA+E;IAC/E,uEAAuE;IACvE,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;SAC/C,WAAW,EAAE;SACb,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEnB,OAAO,GAAG,aAAa,iBAAiB,CAAA;AAC1C,CAAC,CAAC,CACH,CACF,CACF,CACF,CAAA;AApBU,QAAA,QAAQ,YAoBlB"}
@@ -1,62 +0,0 @@
1
- import { generator, when, toFile } from '@feathershq/pinion'
2
- import { getDatabaseAdapter, renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext } from '../index'
4
-
5
- const migrationTemplate = ({
6
- kebabPath,
7
- authStrategies
8
- }: AuthenticationGeneratorContext) => /* ts */ `import type { Knex } from 'knex'
9
-
10
- export async function up(knex: Knex): Promise<void> {
11
- await knex.schema.alterTable('${kebabPath}', function (table) {
12
- table.dropColumn('text')${authStrategies
13
- .map((name) =>
14
- name === 'local'
15
- ? `
16
- table.string('email').unique()
17
- table.string('password')`
18
- : `
19
- table.string('${name}Id')`
20
- )
21
- .join('\n')}
22
- })
23
- }
24
-
25
- export async function down(knex: Knex): Promise<void> {
26
- await knex.schema.alterTable('${kebabPath}', function (table) {
27
- table.string('text')${authStrategies
28
- .map((name) =>
29
- name === 'local'
30
- ? `
31
- table.dropColumn('email')
32
- table.dropColumn('password')`
33
- : `
34
- table.dropColumn('${name}Id')
35
- `
36
- )
37
- .join('\n')}
38
- })
39
- }
40
- `
41
-
42
- export const generate = (ctx: AuthenticationGeneratorContext) =>
43
- generator(ctx).then(
44
- when(
45
- (ctx) => getDatabaseAdapter(ctx.feathers?.database) === 'knex',
46
- renderSource(
47
- migrationTemplate,
48
- toFile(
49
- toFile<AuthenticationGeneratorContext>('migrations', () => {
50
- // Probably not great but it works to align with the Knex migration file format
51
- // We add a few seconds so that the migrations run in the correct order
52
- const migrationDate = new Date(Date.now() + 10000)
53
- .toISOString()
54
- .replace(/\D/g, '')
55
- .substring(0, 14)
56
-
57
- return `${migrationDate}_authentication`
58
- })
59
- )
60
- )
61
- )
62
- )
@@ -1,2 +0,0 @@
1
- import { AuthenticationGeneratorContext } from '../index';
2
- export declare const generate: (ctx: AuthenticationGeneratorContext) => Promise<AuthenticationGeneratorContext>;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const index_1 = require("../index");
7
- const template = ({ cwd, lib, camelName, upperName, authStrategies, type, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
8
- import { resolve, querySyntax, getValidator } from '@feathersjs/schema'
9
- import type { FromSchema } from '@feathersjs/schema'
10
- ${(0, index_1.localTemplate)(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
11
-
12
- import type { HookContext } from '${relative}/declarations'
13
- import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
14
- }validators'
15
-
16
- // Main data model schema
17
- export const ${camelName}Schema = {
18
- $id: '${upperName}',
19
- type: 'object',
20
- additionalProperties: false,
21
- required: [ '${type === 'mongodb' ? '_id' : 'id'}'${(0, index_1.localTemplate)(authStrategies, ", 'email'")} ],
22
- properties: {
23
- ${type === 'mongodb' ? '_id' : 'id'}: {
24
- type: '${type === 'mongodb' ? 'string' : 'number'}'
25
- },
26
- ${authStrategies
27
- .map((name) => name === 'local'
28
- ? ` email: { type: 'string' },
29
- password: { type: 'string' }`
30
- : ` ${name}Id: { type: 'string' }`)
31
- .join(',\n')}
32
- }
33
- } as const
34
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
35
- export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator)
36
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
37
-
38
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
39
- ${(0, index_1.localTemplate)(authStrategies, `// The password should never be visible externally
40
- password: async () => undefined`)}
41
- })
42
-
43
- // Schema for creating new users
44
- export const ${camelName}DataSchema = {
45
- $id: '${upperName}Data',
46
- type: 'object',
47
- additionalProperties: false,
48
- required: [ ],
49
- properties: {
50
- ...${camelName}Schema.properties
51
- }
52
- } as const
53
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
54
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
55
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
56
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
57
- })
58
-
59
- // Schema for updating existing users
60
- export const ${camelName}DataSchema = {
61
- $id: '${upperName}Patch',
62
- type: 'object',
63
- additionalProperties: false,
64
- required: [],
65
- properties: {
66
- ...${camelName}Schema.properties
67
- }
68
- } as const
69
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
70
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
71
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
72
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
73
- })
74
-
75
- // Schema for allowed query properties
76
- export const ${camelName}QuerySchema = {
77
- $id: '${upperName}Query',
78
- type: 'object',
79
- additionalProperties: false,
80
- properties: {
81
- ...querySyntax(${camelName}Schema.properties)
82
- }
83
- } as const
84
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
85
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
86
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
87
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
88
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
89
- if (context.params.user) {
90
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
91
- }
92
-
93
- return value
94
- }
95
- })
96
- `;
97
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'json', (0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
98
- lib,
99
- 'services',
100
- ...folder,
101
- `${fileName}.schema`
102
- ]), { force: true })));
103
- exports.generate = generate;
104
- //# sourceMappingURL=schema.json.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.json.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AACxD,oCAAwE;AAExE,MAAM,QAAQ,GAAG,CAAC,EAChB,GAAG,EACH,GAAG,EACH,SAAS,EACT,SAAS,EACT,cAAc,EACd,IAAI,EACJ,QAAQ,EACuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;EAG7C,IAAA,qBAAa,EAAC,cAAc,EAAE,iEAAiE,CAAC;;oCAE9D,QAAQ;iDACK,QAAQ,IACvD,IAAA,oBAAU,EAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,6CAA6C;AACjG;;;eAGe,SAAS;UACd,SAAS;;;iBAGF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,IAAA,qBAAa,EAAC,cAAc,EAAE,WAAW,CAAC;;MAE1F,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;eACxB,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M,KAAK,MAAM,EACjC,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC;IACpE,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CACF,CAAA;AAfU,QAAA,QAAQ,YAelB"}
@@ -1,125 +0,0 @@
1
- import { generator, toFile, when } from '@feathershq/pinion'
2
- import { fileExists, renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext, localTemplate } from '../index'
4
-
5
- const template = ({
6
- cwd,
7
- lib,
8
- camelName,
9
- upperName,
10
- authStrategies,
11
- type,
12
- relative
13
- }: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
14
- import { resolve, querySyntax, getValidator } from '@feathersjs/schema'
15
- import type { FromSchema } from '@feathersjs/schema'
16
- ${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
17
-
18
- import type { HookContext } from '${relative}/declarations'
19
- import { dataValidator, queryValidator } from '${relative}/${
20
- fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
21
- }validators'
22
-
23
- // Main data model schema
24
- export const ${camelName}Schema = {
25
- $id: '${upperName}',
26
- type: 'object',
27
- additionalProperties: false,
28
- required: [ '${type === 'mongodb' ? '_id' : 'id'}'${localTemplate(authStrategies, ", 'email'")} ],
29
- properties: {
30
- ${type === 'mongodb' ? '_id' : 'id'}: {
31
- type: '${type === 'mongodb' ? 'string' : 'number'}'
32
- },
33
- ${authStrategies
34
- .map((name) =>
35
- name === 'local'
36
- ? ` email: { type: 'string' },
37
- password: { type: 'string' }`
38
- : ` ${name}Id: { type: 'string' }`
39
- )
40
- .join(',\n')}
41
- }
42
- } as const
43
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
44
- export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator)
45
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
46
-
47
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
48
- ${localTemplate(
49
- authStrategies,
50
- `// The password should never be visible externally
51
- password: async () => undefined`
52
- )}
53
- })
54
-
55
- // Schema for creating new users
56
- export const ${camelName}DataSchema = {
57
- $id: '${upperName}Data',
58
- type: 'object',
59
- additionalProperties: false,
60
- required: [ ],
61
- properties: {
62
- ...${camelName}Schema.properties
63
- }
64
- } as const
65
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
66
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
67
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
68
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
69
- })
70
-
71
- // Schema for updating existing users
72
- export const ${camelName}DataSchema = {
73
- $id: '${upperName}Patch',
74
- type: 'object',
75
- additionalProperties: false,
76
- required: [],
77
- properties: {
78
- ...${camelName}Schema.properties
79
- }
80
- } as const
81
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
82
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
83
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
84
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
85
- })
86
-
87
- // Schema for allowed query properties
88
- export const ${camelName}QuerySchema = {
89
- $id: '${upperName}Query',
90
- type: 'object',
91
- additionalProperties: false,
92
- properties: {
93
- ...querySyntax(${camelName}Schema.properties)
94
- }
95
- } as const
96
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
97
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
98
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
99
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
100
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
101
- if (context.params.user) {
102
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
103
- }
104
-
105
- return value
106
- }
107
- })
108
- `
109
-
110
- export const generate = (ctx: AuthenticationGeneratorContext) =>
111
- generator(ctx).then(
112
- when<AuthenticationGeneratorContext>(
113
- ({ schema }) => schema === 'json',
114
- renderSource(
115
- template,
116
- toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
117
- lib,
118
- 'services',
119
- ...folder,
120
- `${fileName}.schema`
121
- ]),
122
- { force: true }
123
- )
124
- )
125
- )
@@ -1,3 +0,0 @@
1
- import { AuthenticationGeneratorContext } from '../index';
2
- export declare const template: ({ cwd, lib, camelName, upperName, authStrategies, type, relative }: AuthenticationGeneratorContext) => string;
3
- export declare const generate: (ctx: AuthenticationGeneratorContext) => Promise<AuthenticationGeneratorContext>;
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = exports.template = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const index_1 = require("../index");
7
- const template = ({ cwd, lib, camelName, upperName, authStrategies, type, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
8
- import { resolve } from '@feathersjs/schema'
9
- import { Type, getValidator, querySyntax } from '@feathersjs/typebox'
10
- import type { Static } from '@feathersjs/typebox'
11
- ${(0, index_1.localTemplate)(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
12
-
13
- import type { HookContext } from '${relative}/declarations'
14
- import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
15
- }validators'
16
-
17
- // Main data model schema
18
- export const ${camelName}Schema = Type.Object({
19
- ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'},
20
- ${authStrategies
21
- .map((name) => name === 'local'
22
- ? ` email: Type.String(),
23
- password: Type.Optional(Type.String())`
24
- : ` ${name}Id: Type.Optional(Type.String())`)
25
- .join(',\n')}
26
- },{ $id: '${upperName}', additionalProperties: false })
27
- export type ${upperName} = Static<typeof ${camelName}Schema>
28
- export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator)
29
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
30
-
31
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
32
- ${(0, index_1.localTemplate)(authStrategies, `// The password should never be visible externally
33
- password: async () => undefined`)}
34
- })
35
-
36
- // Schema for creating new users
37
- export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
38
- ${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
39
- ],
40
- { $id: '${upperName}Data', additionalProperties: false }
41
- )
42
- export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
43
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
44
- export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
45
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
46
- })
47
-
48
- // Schema for updating existing users
49
- export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
50
- $id: '${upperName}Patch'
51
- })
52
- export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
53
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
54
- export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({
55
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
56
- })
57
-
58
- // Schema for allowed query properties
59
- export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${type === 'mongodb' ? '_id' : 'id'}', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
60
- ])
61
- export const ${camelName}QuerySchema = Type.Intersect([
62
- querySyntax(${camelName}QueryProperties),
63
- // Add additional query properties here
64
- Type.Object({}, { additionalProperties: false })
65
- ], { additionalProperties: false })
66
- export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
67
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
68
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
69
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
70
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
71
- if (context.params.user) {
72
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
73
- }
74
-
75
- return value
76
- }
77
- })
78
- `;
79
- exports.template = template;
80
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'typebox', (0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
81
- lib,
82
- 'services',
83
- ...folder,
84
- `${fileName}.schema`
85
- ]), { force: true })));
86
- exports.generate = generate;
87
- //# sourceMappingURL=schema.typebox.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AACxD,oCAAwE;AAEjE,MAAM,QAAQ,GAAG,CAAC,EACvB,GAAG,EACH,GAAG,EACH,SAAS,EACT,SAAS,EACT,cAAc,EACd,IAAI,EACJ,QAAQ,EACuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;EAI7C,IAAA,qBAAa,EAAC,cAAc,EAAE,iEAAiE,CAAC;;oCAE9D,QAAQ;iDACK,QAAQ,IACvD,IAAA,oBAAU,EAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,6CAA6C;AACjG;;;eAGe,SAAS;IACpB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,mBAAmB;IAC/D,cAAc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