@feathersjs/generators 5.0.0-pre.37 → 5.0.0

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 +13 -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 +7 -4
  20. package/lib/app/templates/configuration.tpl.js.map +1 -1
  21. package/lib/app/templates/configuration.tpl.ts +14 -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 +19 -3
  39. package/lib/commons.js +19 -1
  40. package/lib/commons.js.map +1 -1
  41. package/lib/commons.ts +24 -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 +8 -8
  50. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  51. package/lib/connection/templates/mongodb.tpl.ts +11 -9
  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 +1 -3
  57. package/lib/service/templates/client.tpl.js.map +1 -1
  58. package/lib/service/templates/client.tpl.ts +7 -5
  59. package/lib/service/templates/schema.json.tpl.js +43 -22
  60. package/lib/service/templates/schema.json.tpl.js.map +1 -1
  61. package/lib/service/templates/schema.json.tpl.ts +56 -22
  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 +13 -3
  76. package/lib/service/type/knex.tpl.js.map +1 -1
  77. package/lib/service/type/knex.tpl.ts +19 -3
  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 +24 -24
  82. package/lib/authentication/templates/knex.tpl.d.ts +0 -2
  83. package/lib/authentication/templates/knex.tpl.js +0 -37
  84. package/lib/authentication/templates/knex.tpl.js.map +0 -1
  85. package/lib/authentication/templates/knex.tpl.ts +0 -56
  86. package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
  87. package/lib/authentication/templates/schema.json.tpl.js +0 -109
  88. package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
  89. package/lib/authentication/templates/schema.json.tpl.ts +0 -132
  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
@@ -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.37",
3
+ "version": "5.0.0",
4
4
  "description": "Feathers CLI core generators, powered by Pinion",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "keywords": [
@@ -55,40 +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",
58
+ "prettier": "^2.8.4",
59
59
  "typescript": "^4.9.5"
60
60
  },
61
61
  "devDependencies": {
62
- "@feathersjs/adapter-commons": "^5.0.0-pre.37",
63
- "@feathersjs/authentication": "^5.0.0-pre.37",
64
- "@feathersjs/authentication-client": "^5.0.0-pre.37",
65
- "@feathersjs/authentication-local": "^5.0.0-pre.37",
66
- "@feathersjs/authentication-oauth": "^5.0.0-pre.37",
67
- "@feathersjs/configuration": "^5.0.0-pre.37",
68
- "@feathersjs/errors": "^5.0.0-pre.37",
69
- "@feathersjs/express": "^5.0.0-pre.37",
70
- "@feathersjs/feathers": "^5.0.0-pre.37",
71
- "@feathersjs/knex": "^5.0.0-pre.37",
72
- "@feathersjs/koa": "^5.0.0-pre.37",
73
- "@feathersjs/mongodb": "^5.0.0-pre.37",
74
- "@feathersjs/rest-client": "^5.0.0-pre.37",
75
- "@feathersjs/schema": "^5.0.0-pre.37",
76
- "@feathersjs/socketio": "^5.0.0-pre.37",
77
- "@feathersjs/transport-commons": "^5.0.0-pre.37",
78
- "@feathersjs/typebox": "^5.0.0-pre.37",
62
+ "@feathersjs/adapter-commons": "^5.0.0",
63
+ "@feathersjs/authentication": "^5.0.0",
64
+ "@feathersjs/authentication-client": "^5.0.0",
65
+ "@feathersjs/authentication-local": "^5.0.0",
66
+ "@feathersjs/authentication-oauth": "^5.0.0",
67
+ "@feathersjs/configuration": "^5.0.0",
68
+ "@feathersjs/errors": "^5.0.0",
69
+ "@feathersjs/express": "^5.0.0",
70
+ "@feathersjs/feathers": "^5.0.0",
71
+ "@feathersjs/knex": "^5.0.0",
72
+ "@feathersjs/koa": "^5.0.0",
73
+ "@feathersjs/mongodb": "^5.0.0",
74
+ "@feathersjs/rest-client": "^5.0.0",
75
+ "@feathersjs/schema": "^5.0.0",
76
+ "@feathersjs/socketio": "^5.0.0",
77
+ "@feathersjs/transport-commons": "^5.0.0",
78
+ "@feathersjs/typebox": "^5.0.0",
79
79
  "@types/mocha": "^10.0.1",
80
- "@types/node": "^18.11.18",
80
+ "@types/node": "^18.14.1",
81
81
  "@types/prettier": "^2.7.2",
82
- "axios": "^1.3.0",
82
+ "axios": "^1.3.4",
83
83
  "mocha": "^10.2.0",
84
- "mongodb": "^5.0.1",
84
+ "mongodb": "^5.1.0",
85
85
  "mssql": "^9.1.1",
86
86
  "mysql": "^2.18.1",
87
87
  "pg": "^8.9.0",
88
88
  "shx": "^0.3.4",
89
89
  "sqlite3": "^5.1.4",
90
90
  "ts-node": "^10.9.1",
91
- "type-fest": "^3.5.4"
91
+ "type-fest": "^3.6.0"
92
92
  },
93
- "gitHead": "17a8b3b2614876772472d3cab3d96d45c01db6ed"
93
+ "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5"
94
94
  }
@@ -1,2 +0,0 @@
1
- import { AuthenticationGeneratorContext } from '../index';
2
- export declare const generate: (ctx: AuthenticationGeneratorContext) => Promise<AuthenticationGeneratorContext>;
@@ -1,37 +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', async () => `${(0, commons_1.yyyymmddhhmmss)(1200)}_authentication`)))));
36
- exports.generate = generate;
37
- //# 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,2CAAgF;AAGhF,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,EACJ,YAAY,EACZ,KAAK,IAAI,EAAE,CAAC,GAAG,IAAA,wBAAc,EAAC,IAAI,CAAC,iBAAiB,CACrD,CACF,CACF,CACF,CACF,CAAA;AAdU,QAAA,QAAQ,YAclB"}
@@ -1,56 +0,0 @@
1
- import { generator, when, toFile } from '@feathershq/pinion'
2
- import { getDatabaseAdapter, renderSource, yyyymmddhhmmss } 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>(
50
- 'migrations',
51
- async () => `${yyyymmddhhmmss(1200)}_authentication`
52
- )
53
- )
54
- )
55
- )
56
- )
@@ -1,2 +0,0 @@
1
- import { AuthenticationGeneratorContext } from '../index';
2
- export declare const generate: (ctx: AuthenticationGeneratorContext) => Promise<AuthenticationGeneratorContext>;
@@ -1,109 +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'
24
- ? `_id: {
25
- type: 'string',
26
- objectid: true
27
- },`
28
- : `id: {
29
- type: 'number'
30
- },`}
31
- ${authStrategies
32
- .map((name) => name === 'local'
33
- ? ` email: { type: 'string' },
34
- password: { type: 'string' }`
35
- : ` ${name}Id: { type: 'string' }`)
36
- .join(',\n')}
37
- }
38
- } as const
39
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
40
- export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator)
41
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
42
-
43
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
44
- ${(0, index_1.localTemplate)(authStrategies, `// The password should never be visible externally
45
- password: async () => undefined`)}
46
- })
47
-
48
- // Schema for creating new users
49
- export const ${camelName}DataSchema = {
50
- $id: '${upperName}Data',
51
- type: 'object',
52
- additionalProperties: false,
53
- required: [ ],
54
- properties: {
55
- ...${camelName}Schema.properties
56
- }
57
- } as const
58
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
59
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
60
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
61
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
62
- })
63
-
64
- // Schema for updating existing users
65
- export const ${camelName}PatchSchema = {
66
- $id: '${upperName}Patch',
67
- type: 'object',
68
- additionalProperties: false,
69
- required: [],
70
- properties: {
71
- ...${camelName}Schema.properties
72
- }
73
- } as const
74
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
75
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
76
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
77
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
78
- })
79
-
80
- // Schema for allowed query properties
81
- export const ${camelName}QuerySchema = {
82
- $id: '${upperName}Query',
83
- type: 'object',
84
- additionalProperties: false,
85
- properties: {
86
- ...querySyntax(${camelName}Schema.properties)
87
- }
88
- } as const
89
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
90
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
91
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
92
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
93
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
94
- if (context.params.user) {
95
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
96
- }
97
-
98
- return value
99
- }
100
- })
101
- `;
102
- 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 }) => [
103
- lib,
104
- 'services',
105
- ...folder,
106
- `${fileName}.schema`
107
- ]), { force: true })));
108
- exports.generate = generate;
109
- //# 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;;MAG1F,IAAI,KAAK,SAAS;IAChB,CAAC,CAAC;;;OAGH;IACC,CAAC,CAAC;;OAGN;MACE,cAAc;KACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;iCACqB;IACvB,CAAC,CAAC,OAAO,IAAI,wBAAwB,CACxC;KACA,IAAI,CAAC,KAAK,CAAC;;;cAGJ,SAAS,wBAAwB,SAAS;eACzC,SAAS,4BAA4B,SAAS;eAC9C,SAAS,sBAAsB,SAAS;;eAExC,SAAS,8BAA8B,SAAS;IAC3D,IAAA,qBAAa,EACb,cAAc,EACd;kCAC8B,CAC/B;;;;eAIY,SAAS;UACd,SAAS;;;;;SAKV,SAAS;;;cAGJ,SAAS,4BAA4B,SAAS;eAC7C,SAAS,gCAAgC,SAAS;eAClD,SAAS,0BAA0B,SAAS;IACvD,IAAA,qBAAa,EAAC,cAAc,EAAE,+CAA+C,CAAC;;;;eAInE,SAAS;UACd,SAAS;;;;;SAKV,SAAS;;;cAGJ,SAAS,6BAA6B,SAAS;eAC9C,SAAS,iCAAiC,SAAS;eACnD,SAAS,2BAA2B,SAAS;IACxD,IAAA,qBAAa,EAAC,cAAc,EAAE,+CAA+C,CAAC;;;;eAInE,SAAS;UACd,SAAS;;;;qBAIE,SAAS;;;cAGhB,SAAS,6BAA6B,SAAS;eAC9C,SAAS,iCAAiC,SAAS;eACnD,SAAS,2BAA2B,SAAS;;IAExD,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;mCAEF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;;;;CAMnE,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,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,132 +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
- ${
31
- type === 'mongodb'
32
- ? `_id: {
33
- type: 'string',
34
- objectid: true
35
- },`
36
- : `id: {
37
- type: 'number'
38
- },`
39
- }
40
- ${authStrategies
41
- .map((name) =>
42
- name === 'local'
43
- ? ` email: { type: 'string' },
44
- password: { type: 'string' }`
45
- : ` ${name}Id: { type: 'string' }`
46
- )
47
- .join(',\n')}
48
- }
49
- } as const
50
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
51
- export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator)
52
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
53
-
54
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
55
- ${localTemplate(
56
- authStrategies,
57
- `// The password should never be visible externally
58
- password: async () => undefined`
59
- )}
60
- })
61
-
62
- // Schema for creating new users
63
- export const ${camelName}DataSchema = {
64
- $id: '${upperName}Data',
65
- type: 'object',
66
- additionalProperties: false,
67
- required: [ ],
68
- properties: {
69
- ...${camelName}Schema.properties
70
- }
71
- } as const
72
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
73
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
74
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
75
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
76
- })
77
-
78
- // Schema for updating existing users
79
- export const ${camelName}PatchSchema = {
80
- $id: '${upperName}Patch',
81
- type: 'object',
82
- additionalProperties: false,
83
- required: [],
84
- properties: {
85
- ...${camelName}Schema.properties
86
- }
87
- } as const
88
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
89
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
90
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
91
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
92
- })
93
-
94
- // Schema for allowed query properties
95
- export const ${camelName}QuerySchema = {
96
- $id: '${upperName}Query',
97
- type: 'object',
98
- additionalProperties: false,
99
- properties: {
100
- ...querySyntax(${camelName}Schema.properties)
101
- }
102
- } as const
103
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
104
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
105
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
106
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
107
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
108
- if (context.params.user) {
109
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
110
- }
111
-
112
- return value
113
- }
114
- })
115
- `
116
-
117
- export const generate = (ctx: AuthenticationGeneratorContext) =>
118
- generator(ctx).then(
119
- when<AuthenticationGeneratorContext>(
120
- ({ schema }) => schema === 'json',
121
- renderSource(
122
- template,
123
- toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
124
- lib,
125
- 'services',
126
- ...folder,
127
- `${fileName}.schema`
128
- ]),
129
- { force: true }
130
- )
131
- )
132
- )
@@ -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({ objectid: true })' : '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":"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"}
@@ -1,109 +0,0 @@
1
- import { generator, toFile, when } from '@feathershq/pinion'
2
- import { fileExists, renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext, localTemplate } from '../index'
4
-
5
- export 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 } from '@feathersjs/schema'
15
- import { Type, getValidator, querySyntax } from '@feathersjs/typebox'
16
- import type { Static } from '@feathersjs/typebox'
17
- ${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
18
-
19
- import type { HookContext } from '${relative}/declarations'
20
- import { dataValidator, queryValidator } from '${relative}/${
21
- fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
22
- }validators'
23
-
24
- // Main data model schema
25
- export const ${camelName}Schema = Type.Object({
26
- ${type === 'mongodb' ? '_id: Type.String({ objectid: true })' : 'id: Type.Number()'},
27
- ${authStrategies
28
- .map((name) =>
29
- name === 'local'
30
- ? ` email: Type.String(),
31
- password: Type.Optional(Type.String())`
32
- : ` ${name}Id: Type.Optional(Type.String())`
33
- )
34
- .join(',\n')}
35
- },{ $id: '${upperName}', additionalProperties: false })
36
- export type ${upperName} = Static<typeof ${camelName}Schema>
37
- export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator)
38
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
39
-
40
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
41
- ${localTemplate(
42
- authStrategies,
43
- `// The password should never be visible externally
44
- password: async () => undefined`
45
- )}
46
- })
47
-
48
- // Schema for creating new users
49
- export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
50
- ${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
51
- ],
52
- { $id: '${upperName}Data', additionalProperties: false }
53
- )
54
- export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
55
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
56
- export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
57
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
58
- })
59
-
60
- // Schema for updating existing users
61
- export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
62
- $id: '${upperName}Patch'
63
- })
64
- export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
65
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
66
- export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({
67
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
68
- })
69
-
70
- // Schema for allowed query properties
71
- export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${
72
- type === 'mongodb' ? '_id' : 'id'
73
- }', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
74
- ])
75
- export const ${camelName}QuerySchema = Type.Intersect([
76
- querySyntax(${camelName}QueryProperties),
77
- // Add additional query properties here
78
- Type.Object({}, { additionalProperties: false })
79
- ], { additionalProperties: false })
80
- export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
81
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
82
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
83
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
84
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
85
- if (context.params.user) {
86
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
87
- }
88
-
89
- return value
90
- }
91
- })
92
- `
93
-
94
- export const generate = (ctx: AuthenticationGeneratorContext) =>
95
- generator(ctx).then(
96
- when<AuthenticationGeneratorContext>(
97
- ({ schema }) => schema === 'typebox',
98
- renderSource(
99
- template,
100
- toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
101
- lib,
102
- 'services',
103
- ...folder,
104
- `${fileName}.schema`
105
- ]),
106
- { force: true }
107
- )
108
- )
109
- )