@feathersjs/cli 5.0.0-pre.26 → 5.0.0-pre.27

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 (86) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/lib/app/index.js +1 -1
  3. package/lib/app/index.js.map +1 -1
  4. package/lib/app/index.ts +1 -1
  5. package/lib/app/templates/app.tpl.js +2 -2
  6. package/lib/app/templates/app.tpl.ts +2 -2
  7. package/lib/app/templates/client.tpl.js +1 -1
  8. package/lib/app/templates/client.tpl.ts +1 -1
  9. package/lib/app/templates/configuration.tpl.js +23 -20
  10. package/lib/app/templates/configuration.tpl.js.map +1 -1
  11. package/lib/app/templates/configuration.tpl.ts +23 -20
  12. package/lib/app/templates/declarations.tpl.js +1 -1
  13. package/lib/app/templates/declarations.tpl.ts +1 -1
  14. package/lib/app/templates/package.json.tpl.js +2 -0
  15. package/lib/app/templates/package.json.tpl.js.map +1 -1
  16. package/lib/app/templates/package.json.tpl.ts +2 -0
  17. package/lib/app/templates/prettierrc.tpl.d.ts +2 -0
  18. package/lib/app/templates/prettierrc.tpl.js +11 -0
  19. package/lib/app/templates/prettierrc.tpl.js.map +1 -0
  20. package/lib/app/templates/prettierrc.tpl.ts +14 -0
  21. package/lib/authentication/index.d.ts +0 -2
  22. package/lib/authentication/templates/authentication.tpl.js +3 -3
  23. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  24. package/lib/authentication/templates/authentication.tpl.ts +5 -5
  25. package/lib/authentication/templates/declarations.tpl.js +1 -1
  26. package/lib/authentication/templates/declarations.tpl.js.map +1 -1
  27. package/lib/authentication/templates/declarations.tpl.ts +2 -2
  28. package/lib/authentication/templates/knex.tpl.js +6 -5
  29. package/lib/authentication/templates/knex.tpl.js.map +1 -1
  30. package/lib/authentication/templates/knex.tpl.ts +16 -17
  31. package/lib/authentication/templates/test.tpl.js +2 -2
  32. package/lib/authentication/templates/test.tpl.js.map +1 -1
  33. package/lib/authentication/templates/test.tpl.ts +2 -2
  34. package/lib/authentication/templates/user.resolver.tpl.js +6 -6
  35. package/lib/authentication/templates/user.resolver.tpl.js.map +1 -1
  36. package/lib/authentication/templates/user.resolver.tpl.ts +6 -6
  37. package/lib/authentication/templates/user.schema.tpl.js +7 -13
  38. package/lib/authentication/templates/user.schema.tpl.js.map +1 -1
  39. package/lib/authentication/templates/user.schema.tpl.ts +7 -13
  40. package/lib/commons.d.ts +19 -9
  41. package/lib/commons.js +56 -23
  42. package/lib/commons.js.map +1 -1
  43. package/lib/commons.ts +87 -26
  44. package/lib/connection/templates/knex.tpl.js +13 -16
  45. package/lib/connection/templates/knex.tpl.js.map +1 -1
  46. package/lib/connection/templates/knex.tpl.ts +18 -20
  47. package/lib/connection/templates/mongodb.tpl.js +5 -9
  48. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  49. package/lib/connection/templates/mongodb.tpl.ts +10 -12
  50. package/lib/index.js +2 -1
  51. package/lib/index.js.map +1 -1
  52. package/lib/index.ts +2 -1
  53. package/lib/service/index.d.ts +0 -16
  54. package/lib/service/index.js +3 -8
  55. package/lib/service/index.js.map +1 -1
  56. package/lib/service/index.ts +3 -16
  57. package/lib/service/templates/class.tpl.d.ts +2 -0
  58. package/lib/service/templates/class.tpl.js +63 -0
  59. package/lib/service/templates/class.tpl.js.map +1 -0
  60. package/lib/service/templates/class.tpl.ts +79 -0
  61. package/lib/service/templates/client.tpl.js +4 -6
  62. package/lib/service/templates/client.tpl.js.map +1 -1
  63. package/lib/service/templates/client.tpl.ts +10 -15
  64. package/lib/service/templates/resolver.tpl.js +4 -4
  65. package/lib/service/templates/resolver.tpl.js.map +1 -1
  66. package/lib/service/templates/resolver.tpl.ts +4 -4
  67. package/lib/service/templates/schema.tpl.js +2 -2
  68. package/lib/service/templates/schema.tpl.js.map +1 -1
  69. package/lib/service/templates/schema.tpl.ts +2 -2
  70. package/lib/service/templates/service.tpl.js +12 -58
  71. package/lib/service/templates/service.tpl.js.map +1 -1
  72. package/lib/service/templates/service.tpl.ts +17 -79
  73. package/lib/service/templates/test.tpl.js +4 -4
  74. package/lib/service/templates/test.tpl.js.map +1 -1
  75. package/lib/service/templates/test.tpl.ts +4 -4
  76. package/lib/service/type/custom.tpl.d.ts +1 -1
  77. package/lib/service/type/custom.tpl.js +24 -16
  78. package/lib/service/type/custom.tpl.js.map +1 -1
  79. package/lib/service/type/custom.tpl.ts +28 -19
  80. package/lib/service/type/knex.tpl.js +11 -5
  81. package/lib/service/type/knex.tpl.js.map +1 -1
  82. package/lib/service/type/knex.tpl.ts +14 -9
  83. package/lib/service/type/mongodb.tpl.js +11 -5
  84. package/lib/service/type/mongodb.tpl.js.map +1 -1
  85. package/lib/service/type/mongodb.tpl.ts +14 -9
  86. package/package.json +19 -19
@@ -1,6 +1,6 @@
1
- import { generator, toFile, inject, before } from '@feathershq/pinion'
1
+ import { generator, toFile, before } from '@feathershq/pinion'
2
2
  import { ConnectionGeneratorContext } from '../index'
3
- import { getSource, renderSource } from '../../commons'
3
+ import { injectSource, renderSource } from '../../commons'
4
4
 
5
5
  const template = ({}: ConnectionGeneratorContext) =>
6
6
  `import { MongoClient } from 'mongodb'
@@ -22,11 +22,12 @@ export const mongodb = (app: Application) => {
22
22
  app.set('mongodbClient', mongoClient)
23
23
  }
24
24
  `
25
+
25
26
  const configurationTemplate = ({ database }: ConnectionGeneratorContext) =>
26
- ` ${database}: { type: 'string' },`
27
+ ` ${database}: { type: 'string' },`
27
28
  const importTemplate = "import { mongodb } from './mongodb'"
28
29
  const configureTemplate = 'app.configure(mongodb)'
29
- const toAppFile = toFile<ConnectionGeneratorContext>(({ lib, language }) => [lib, `app.${language}`])
30
+ const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
30
31
 
31
32
  export const generate = (ctx: ConnectionGeneratorContext) =>
32
33
  generator(ctx)
@@ -37,15 +38,12 @@ export const generate = (ctx: ConnectionGeneratorContext) =>
37
38
  )
38
39
  )
39
40
  .then(
40
- inject(
41
+ injectSource(
41
42
  configurationTemplate,
42
43
  before('authentication: authenticationSettingsSchema'),
43
- toFile<ConnectionGeneratorContext>(({ lib, language }) => [
44
- lib,
45
- 'schemas',
46
- `configuration.schema.${language}`
47
- ])
44
+ toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'configuration']),
45
+ false
48
46
  )
49
47
  )
50
- .then(inject(getSource(importTemplate), before('import { services } from'), toAppFile))
51
- .then(inject(getSource(configureTemplate), before('app.configure(services)'), toAppFile))
48
+ .then(injectSource(importTemplate, before('import { services } from'), toAppFile))
49
+ .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
package/lib/index.js CHANGED
@@ -18,8 +18,9 @@ const command = (yargs) => yargs
18
18
  .command('generate', 'Run a generator', (yarg) => yarg
19
19
  .command('app', 'Generate a new app', exports.commandRunner)
20
20
  .command('service', 'Generate a service', exports.commandRunner)
21
+ .command('hook', 'Generate a hook', exports.commandRunner)
21
22
  .command('connection', 'Connect to a different database', exports.commandRunner)
22
- .command('hook', 'Generate a hook', exports.commandRunner))
23
+ .command('authentication', 'Set up authentication with a custom entity', exports.commandRunner))
23
24
  .usage('Usage: $0 <command> [options]')
24
25
  .help();
25
26
  exports.command = command;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,uCAAsE;AAE/D,MAAM,aAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IACzC,MAAM,GAAG,GAAG,IAAA,mBAAU,EAAsB;QAC1C,GAAG,IAAI,CAAC,IAAI;KACb,CAAC,CAAA;IAEF,OAAO,IAAA,gBAAQ,EAAC,GAAG,CAAC,CAAA;AACtB,CAAC,CAAA;AANY,QAAA,aAAa,iBAMzB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BA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AAC,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAA;AAH3E,QAAA,QAAQ,YAGmE;AAEjF,MAAM,OAAO,GAAG,CAAC,KAAW,EAAE,EAAE,CACrC,KAAK;KACF,OAAO,CAAC,UAAU,EAAE,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC/C,IAAI;KACD,OAAO,CAAC,KAAK,EAAE,oBAAoB,EAAE,qBAAa,CAAC;KACnD,OAAO,CAAC,SAAS,EAAE,oBAAoB,EAAE,qBAAa,CAAC;KACvD,OAAO,CAAC,MAAM,EAAE,iBAAiB,EAAE,qBAAa,CAAC;KACjD,OAAO,CAAC,YAAY,EAAE,iCAAiC,EAAE,qBAAa,CAAC;KACvE,OAAO,CAAC,gBAAgB,EAAE,4CAA4C,EAAE,qBAAa,CAAC,CAC1F;KACA,KAAK,CAAC,+BAA+B,CAAC;KACtC,IAAI,EAAE,CAAA;AAXE,QAAA,OAAO,WAWT"}
package/lib/index.ts CHANGED
@@ -20,8 +20,9 @@ export const command = (yargs: Argv) =>
20
20
  yarg
21
21
  .command('app', 'Generate a new app', commandRunner)
22
22
  .command('service', 'Generate a service', commandRunner)
23
- .command('connection', 'Connect to a different database', commandRunner)
24
23
  .command('hook', 'Generate a hook', commandRunner)
24
+ .command('connection', 'Connect to a different database', commandRunner)
25
+ .command('authentication', 'Set up authentication with a custom entity', commandRunner)
25
26
  )
26
27
  .usage('Usage: $0 <command> [options]')
27
28
  .help()
@@ -48,14 +48,6 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
48
48
  * Set to true if this service is for an authentication entity
49
49
  */
50
50
  isEntityService?: boolean;
51
- /**
52
- * The name of the schema file
53
- */
54
- schemaPath: string;
55
- /**
56
- * The name of the resolver file
57
- */
58
- resolverPath: string;
59
51
  }
60
52
  /**
61
53
  * Parameters the generator is called with
@@ -110,14 +102,6 @@ export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
110
102
  * Set to true if this service is for an authentication entity
111
103
  */
112
104
  isEntityService?: boolean;
113
- /**
114
- * The name of the schema file
115
- */
116
- schemaPath: string;
117
- /**
118
- * The name of the resolver file
119
- */
120
- resolverPath: string;
121
105
  feathers: import("../commons").FeathersAppInfo;
122
106
  pkg: import("../commons").AppPackageJson;
123
107
  lib: string;
@@ -56,12 +56,9 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
56
56
  const camelName = lodash_1.default.camelCase(name);
57
57
  const upperName = lodash_1.default.upperFirst(camelName);
58
58
  const className = `${upperName}Service`;
59
- const pathElements = path.split('/').filter((el) => el !== '');
60
- const relative = pathElements.map(() => '..').join('/');
61
- const folder = lodash_1.default.initial(pathElements);
62
- const fileName = lodash_1.default.last(pathElements);
63
- const schemaPath = ['schemas', ...folder, `${fileName}.schema`].join('/');
64
- const resolverPath = ['resolvers', ...folder, `${fileName}.resolver`].join('/');
59
+ const folder = path.split('/').filter((el) => el !== '');
60
+ const relative = ['', ...folder].map(() => '..').join('/');
61
+ const fileName = lodash_1.default.last(folder);
65
62
  return {
66
63
  name,
67
64
  type,
@@ -73,8 +70,6 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
73
70
  kebabName,
74
71
  camelName,
75
72
  relative,
76
- resolverPath,
77
- schemaPath,
78
73
  ...ctx
79
74
  };
80
75
  })
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,wCAAoE;AAmE7D,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAE,EAAE,CACzD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,eAAM,EACJ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;IACzD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,IAAI;QACX,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CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,gBAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACzC,MAAM,SAAS,GAAG,GAAG,SAAS,SAAS,CAAA;IAEvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IACxD,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1D,MAAM,QAAQ,GAAG,gBAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE/B,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,QAAQ;QACR,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,QAAQ;QACR,GAAG,GAAG;KACP,CAAA;AACH,CAAC,CAAC;KACD,IAAI,CAAC,IAAA,sBAAa,EAA0B,SAAS,EAAE,WAAW,CAAC,CAAC;KACpE,IAAI,CAAC,IAAA,qBAAY,EAA0B,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAA;AA1EnF,QAAA,QAAQ,YA0E2E"}
@@ -52,14 +52,6 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
52
52
  * Set to true if this service is for an authentication entity
53
53
  */
54
54
  isEntityService?: boolean
55
- /**
56
- * The name of the schema file
57
- */
58
- schemaPath: string
59
- /**
60
- * The name of the resolver file
61
- */
62
- resolverPath: string
63
55
  }
64
56
 
65
57
  /**
@@ -123,12 +115,9 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
123
115
  const upperName = _.upperFirst(camelName)
124
116
  const className = `${upperName}Service`
125
117
 
126
- const pathElements = path.split('/').filter((el) => el !== '')
127
- const relative = pathElements.map(() => '..').join('/')
128
- const folder = _.initial(pathElements)
129
- const fileName = _.last(pathElements)
130
- const schemaPath = ['schemas', ...folder, `${fileName}.schema`].join('/')
131
- const resolverPath = ['resolvers', ...folder, `${fileName}.resolver`].join('/')
118
+ const folder = path.split('/').filter((el) => el !== '')
119
+ const relative = ['', ...folder].map(() => '..').join('/')
120
+ const fileName = _.last(folder)
132
121
 
133
122
  return {
134
123
  name,
@@ -141,8 +130,6 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
141
130
  kebabName,
142
131
  camelName,
143
132
  relative,
144
- resolverPath,
145
- schemaPath,
146
133
  ...ctx
147
134
  }
148
135
  })
@@ -0,0 +1,2 @@
1
+ import { ServiceGeneratorContext } from '../index';
2
+ export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -0,0 +1,63 @@
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 template = ({ camelName, upperName, fileName, isEntityService, authentication }) => `import { resolveAll } from '@feathersjs/schema'
7
+ ${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
8
+ import type {
9
+ ${upperName}Data,
10
+ ${upperName}Result,
11
+ ${upperName}Query,
12
+ } from './${fileName}.schema'
13
+ import { ${camelName}Resolvers } from './${fileName}.resolver'
14
+
15
+ export const ${camelName}Hooks = {
16
+ around: {
17
+ all: [${authentication
18
+ ? `
19
+ authenticate('jwt'),`
20
+ : ''} ${!isEntityService
21
+ ? `
22
+ resolveAll(${camelName}Resolvers)`
23
+ : ''}
24
+ ]${isEntityService
25
+ ? `,
26
+ get: [
27
+ authenticate('jwt'),
28
+ resolveAll(${camelName}Resolvers)
29
+ ],
30
+ find: [
31
+ authenticate('jwt'),
32
+ resolveAll(${camelName}Resolvers)
33
+ ],
34
+ create: [
35
+ resolveAll(${camelName}Resolvers)
36
+ ],
37
+ patch: [
38
+ authenticate('jwt'),
39
+ resolveAll(${camelName}Resolvers)
40
+ ],
41
+ update: [
42
+ authenticate('jwt'),
43
+ resolveAll(${camelName}Resolvers)
44
+ ],
45
+ remove: [
46
+ authenticate('jwt'),
47
+ resolveAll(${camelName}Resolvers)
48
+ ]`
49
+ : ''}
50
+ },
51
+ before: {},
52
+ after: {},
53
+ error: {}
54
+ }
55
+ `;
56
+ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
57
+ lib,
58
+ 'services',
59
+ ...folder,
60
+ `${fileName}.class`
61
+ ])));
62
+ exports.generate = generate;
63
+ //# sourceMappingURL=class.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/class.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,eAAe,EACf,cAAc,EACU,EAAE,EAAE,CAC5B;EACA,eAAe,IAAI,cAAc,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC,EAAE;;IAElG,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;WACT,SAAS,uBAAuB,QAAQ;;eAEpC,SAAS;;YAGlB,cAAc;IACZ,CAAC,CAAC;2BACiB;IACnB,CAAC,CAAC,EACN,IACA,CAAC,eAAe;IACd,CAAC,CAAC;mBACW,SAAS,YAAY;IAClC,CAAC,CAAC,EACN;OAEI,eAAe;IACb,CAAC,CAAC;;;mBAGS,SAAS;;;;mBAIT,SAAS;;;mBAGT,SAAS;;;;mBAIT,SAAS;;;;mBAIT,SAAS;;;;mBAIT,SAAS;MACtB;IACE,CAAC,CAAC,EACN;;;;;;CAMH,CAAA;AACM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,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"}
@@ -0,0 +1,79 @@
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
+ import { ServiceGeneratorContext } from '../index'
4
+
5
+ const template = ({
6
+ camelName,
7
+ upperName,
8
+ fileName,
9
+ isEntityService,
10
+ authentication
11
+ }: ServiceGeneratorContext) =>
12
+ `import { resolveAll } from '@feathersjs/schema'
13
+ ${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
14
+ import type {
15
+ ${upperName}Data,
16
+ ${upperName}Result,
17
+ ${upperName}Query,
18
+ } from './${fileName}.schema'
19
+ import { ${camelName}Resolvers } from './${fileName}.resolver'
20
+
21
+ export const ${camelName}Hooks = {
22
+ around: {
23
+ all: [${
24
+ authentication
25
+ ? `
26
+ authenticate('jwt'),`
27
+ : ''
28
+ } ${
29
+ !isEntityService
30
+ ? `
31
+ resolveAll(${camelName}Resolvers)`
32
+ : ''
33
+ }
34
+ ]${
35
+ isEntityService
36
+ ? `,
37
+ get: [
38
+ authenticate('jwt'),
39
+ resolveAll(${camelName}Resolvers)
40
+ ],
41
+ find: [
42
+ authenticate('jwt'),
43
+ resolveAll(${camelName}Resolvers)
44
+ ],
45
+ create: [
46
+ resolveAll(${camelName}Resolvers)
47
+ ],
48
+ patch: [
49
+ authenticate('jwt'),
50
+ resolveAll(${camelName}Resolvers)
51
+ ],
52
+ update: [
53
+ authenticate('jwt'),
54
+ resolveAll(${camelName}Resolvers)
55
+ ],
56
+ remove: [
57
+ authenticate('jwt'),
58
+ resolveAll(${camelName}Resolvers)
59
+ ]`
60
+ : ''
61
+ }
62
+ },
63
+ before: {},
64
+ after: {},
65
+ error: {}
66
+ }
67
+ `
68
+ export const generate = (ctx: ServiceGeneratorContext) =>
69
+ generator(ctx).then(
70
+ renderSource(
71
+ template,
72
+ toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
73
+ lib,
74
+ 'services',
75
+ ...folder,
76
+ `${fileName}.class`
77
+ ])
78
+ )
79
+ )
@@ -2,15 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
- const schemaImports = ({ upperName, schemaPath }) => `import type {
5
+ const schemaImports = ({ upperName, folder, fileName }) => `import type {
6
6
  ${upperName}Data,
7
7
  ${upperName}Result,
8
8
  ${upperName}Query,
9
- } from './${schemaPath}'`;
9
+ } from './services/${folder.join('/')}/${fileName}.schema'`;
10
10
  const declarationTemplate = ({ path, upperName }) => ` '${path}': Service<${upperName}Data, ${upperName}Result, Params<${upperName}Query>>`;
11
- const toClientFile = (0, pinion_1.toFile)(({ lib, language }) => [lib, `client.${language}`]);
12
- const generate = async (ctx) => (0, pinion_1.generator)(ctx)
13
- .then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.inject)(schemaImports, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile)))
14
- .then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.inject)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
11
+ const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client.ts']);
12
+ const generate = async (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.inject)(schemaImports, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile), (0, pinion_1.inject)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
15
13
  exports.generate = generate;
16
14
  //# sourceMappingURL=client.tpl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA2E;AAG3E,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAA2B,EAAE,EAAE,CAAC;IAC1E,SAAS;IACT,SAAS;IACT,SAAS;YACD,UAAU,GAAG,CAAA;AACzB,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC3E,MAAM,IAAI,cAAc,SAAS,SAAS,SAAS,kBAAkB,SAAS,SAAS,CAAA;AAEzF,MAAM,YAAY,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,QAAQ,EAAE,CAAC,CAAC,CAAA;AAEjG,MAAM,QAAQ,GAAG,KAAK,EAAE,GAA4B,EAAE,EAAE,CAC7D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,eAAM,EAAC,aAAa,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,CAC1E,CACF;KACA,IAAI,CACH,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,eAAM,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CAClF,CACF,CAAA;AAbQ,QAAA,QAAQ,YAahB"}
1
+ {"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA2E;AAG3E,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAChF,SAAS;IACT,SAAS;IACT,SAAS;qBACQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,UAAU,CAAA;AAE3D,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC3E,MAAM,IAAI,cAAc,SAAS,SAAS,SAAS,kBAAkB,SAAS,SAAS,CAAA;AAEzF,MAAM,YAAY,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAA;AAE9E,MAAM,QAAQ,GAAG,KAAK,EAAE,GAA4B,EAAE,EAAE,CAC7D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,eAAM,EAAC,aAAa,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,EACzE,IAAA,eAAM,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CAClF,CACF,CAAA;AAPU,QAAA,QAAQ,YAOlB"}
@@ -1,27 +1,22 @@
1
1
  import { generator, inject, toFile, when, after } from '@feathershq/pinion'
2
2
  import { ServiceGeneratorContext } from '../index'
3
3
 
4
- const schemaImports = ({ upperName, schemaPath }: ServiceGeneratorContext) => `import type {
4
+ const schemaImports = ({ upperName, folder, fileName }: ServiceGeneratorContext) => `import type {
5
5
  ${upperName}Data,
6
6
  ${upperName}Result,
7
7
  ${upperName}Query,
8
- } from './${schemaPath}'`
8
+ } from './services/${folder.join('/')}/${fileName}.schema'`
9
+
9
10
  const declarationTemplate = ({ path, upperName }: ServiceGeneratorContext) =>
10
11
  ` '${path}': Service<${upperName}Data, ${upperName}Result, Params<${upperName}Query>>`
11
12
 
12
- const toClientFile = toFile<ServiceGeneratorContext>(({ lib, language }) => [lib, `client.${language}`])
13
+ const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client.ts'])
13
14
 
14
15
  export const generate = async (ctx: ServiceGeneratorContext) =>
15
- generator(ctx)
16
- .then(
17
- when(
18
- (ctx) => ctx.language === 'ts',
19
- inject(schemaImports, after("from '@feathersjs/feathers'"), toClientFile)
20
- )
21
- )
22
- .then(
23
- when(
24
- (ctx) => ctx.language === 'ts',
25
- inject(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
26
- )
16
+ generator(ctx).then(
17
+ when(
18
+ (ctx) => ctx.language === 'ts',
19
+ inject(schemaImports, after("from '@feathersjs/feathers'"), toClientFile),
20
+ inject(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
27
21
  )
22
+ )
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const template = ({ camelName, upperName, relative, schemaPath }) => `import { resolve } from '@feathersjs/schema'
6
+ const template = ({ camelName, upperName, relative, fileName }) => `import { resolve } from '@feathersjs/schema'
7
7
  import type { HookContext } from '${relative}/declarations'
8
8
 
9
9
  import type {
@@ -11,13 +11,13 @@ import type {
11
11
  ${upperName}Patch,
12
12
  ${upperName}Result,
13
13
  ${upperName}Query,
14
- } from '${relative}/${schemaPath}'
14
+ } from './${fileName}.schema'
15
15
  import {
16
16
  ${camelName}DataSchema,
17
17
  ${camelName}PatchSchema,
18
18
  ${camelName}ResultSchema,
19
19
  ${camelName}QuerySchema
20
- } from '${relative}/${schemaPath}'
20
+ } from './${fileName}.schema'
21
21
 
22
22
 
23
23
  // Resolver for the basic data model (e.g. creating new entries)
@@ -65,7 +65,7 @@ export const ${camelName}Resolvers = {
65
65
  `;
66
66
  const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
67
67
  lib,
68
- 'resolvers',
68
+ 'services',
69
69
  ...folder,
70
70
  `${fileName}.resolver`
71
71
  ])));
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/resolver.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAA2B,EAAE,EAAE,CAC3F;oCACkC,QAAQ;;;IAGxC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;UACH,QAAQ,IAAI,UAAU;;IAE5B,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;UACH,QAAQ,IAAI,UAAU;;;;eAIjB,SAAS,0BAA0B,SAAS;YAC/C,SAAS;;;;;;;eAON,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;;;;eAON,SAAS,4BAA4B,SAAS;YACjD,SAAS;;;;;;;eAON,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;;;;eAON,SAAS;YACZ,SAAS;;cAEP,SAAS;cACT,SAAS;aACV,SAAS;;WAEX,SAAS;;CAEnB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,WAAW;IACX,GAAG,MAAM;IACT,GAAG,QAAQ,WAAW;CACvB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
1
+ {"version":3,"file":"resolver.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/resolver.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAA2B,EAAE,EAAE,CACzF;oCACkC,QAAQ;;;IAGxC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;;IAEhB,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;;;;eAIL,SAAS,0BAA0B,SAAS;YAC/C,SAAS;;;;;;;eAON,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;;;;eAON,SAAS,4BAA4B,SAAS;YACjD,SAAS;;;;;;;eAON,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;;;;eAON,SAAS;YACZ,SAAS;;cAEP,SAAS;cACT,SAAS;aACV,SAAS;;WAEX,SAAS;;CAEnB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,WAAW;CACvB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
@@ -2,7 +2,7 @@ import { generator, toFile } from '@feathershq/pinion'
2
2
  import { renderSource } from '../../commons'
3
3
  import { ServiceGeneratorContext } from '../index'
4
4
 
5
- const template = ({ camelName, upperName, relative, schemaPath }: ServiceGeneratorContext) =>
5
+ const template = ({ camelName, upperName, relative, fileName }: ServiceGeneratorContext) =>
6
6
  `import { resolve } from '@feathersjs/schema'
7
7
  import type { HookContext } from '${relative}/declarations'
8
8
 
@@ -11,13 +11,13 @@ import type {
11
11
  ${upperName}Patch,
12
12
  ${upperName}Result,
13
13
  ${upperName}Query,
14
- } from '${relative}/${schemaPath}'
14
+ } from './${fileName}.schema'
15
15
  import {
16
16
  ${camelName}DataSchema,
17
17
  ${camelName}PatchSchema,
18
18
  ${camelName}ResultSchema,
19
19
  ${camelName}QuerySchema
20
- } from '${relative}/${schemaPath}'
20
+ } from './${fileName}.schema'
21
21
 
22
22
 
23
23
  // Resolver for the basic data model (e.g. creating new entries)
@@ -70,7 +70,7 @@ export const generate = (ctx: ServiceGeneratorContext) =>
70
70
  template,
71
71
  toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
72
72
  lib,
73
- 'resolvers',
73
+ 'services',
74
74
  ...folder,
75
75
  `${fileName}.resolver`
76
76
  ])
@@ -45,7 +45,7 @@ export const ${camelName}ResultSchema = schema({
45
45
  properties: {
46
46
  ...${camelName}DataSchema.properties,
47
47
  ${type === 'mongodb' ? '_id' : 'id'}: {
48
- type: 'string'
48
+ type: '${type === 'mongodb' ? 'string' : 'number'}'
49
49
  }
50
50
  }
51
51
  } as const)
@@ -67,7 +67,7 @@ export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
67
67
  `;
68
68
  const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
69
69
  lib,
70
- 'schemas',
70
+ 'services',
71
71
  ...folder,
72
72
  `${fileName}.schema`
73
73
  ])));
@@ -1 +1 @@
1
- {"version":3,"file":"schema.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAA2B,EAAE,EAAE,CAC3E;;;;eAIa,SAAS;UACd,SAAS;;;;;;;;;;;cAWL,SAAS,uBAAuB,SAAS;;;;eAIxC,SAAS;UACd,SAAS;;;;;SAKV,SAAS;;;;cAIJ,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CAAC,IAAI;eACxB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;;;;;cAKzC,SAAS,yBAAyB,SAAS;;;;eAI1C,SAAS;UACd,SAAS;;;;qBAIE,SAAS;;;;cAIhB,SAAS,wBAAwB,SAAS;CACvD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
@@ -45,7 +45,7 @@ export const ${camelName}ResultSchema = schema({
45
45
  properties: {
46
46
  ...${camelName}DataSchema.properties,
47
47
  ${type === 'mongodb' ? '_id' : 'id'}: {
48
- type: 'string'
48
+ type: '${type === 'mongodb' ? 'string' : 'number'}'
49
49
  }
50
50
  }
51
51
  } as const)
@@ -72,7 +72,7 @@ export const generate = (ctx: ServiceGeneratorContext) =>
72
72
  template,
73
73
  toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
74
74
  lib,
75
- 'schemas',
75
+ 'services',
76
76
  ...folder,
77
77
  `${fileName}.schema`
78
78
  ])
@@ -3,56 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const template = ({ relative, path, className, schemaPath, resolverPath, camelName, upperName, isEntityService, authentication }) => `import { resolveAll } from '@feathersjs/schema'
7
- ${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
8
- import type { Application } from '${relative}/declarations'
9
- import type {
10
- ${upperName}Data,
11
- ${upperName}Result,
12
- ${upperName}Query,
13
- } from '${relative}/${schemaPath}'
14
- import { ${camelName}Resolvers } from '${relative}/${resolverPath}'
6
+ const template = ({ relative, path, className, camelName, fileName }) => `import type { Application } from '${relative}/declarations'
15
7
 
16
- export const hooks = {
17
- around: {
18
- all: [${authentication
19
- ? `
20
- authenticate('jwt'),`
21
- : ''} ${!isEntityService
22
- ? `
23
- resolveAll(${camelName}Resolvers)`
24
- : ''}
25
- ]${isEntityService
26
- ? `,
27
- get: [
28
- authenticate('jwt'),
29
- resolveAll(${camelName}Resolvers)
30
- ],
31
- find: [
32
- authenticate('jwt'),
33
- resolveAll(${camelName}Resolvers)
34
- ],
35
- create: [
36
- resolveAll(${camelName}Resolvers)
37
- ],
38
- patch: [
39
- authenticate('jwt'),
40
- resolveAll(${camelName}Resolvers)
41
- ],
42
- update: [
43
- authenticate('jwt'),
44
- resolveAll(${camelName}Resolvers)
45
- ],
46
- remove: [
47
- authenticate('jwt'),
48
- resolveAll(${camelName}Resolvers)
49
- ]`
50
- : ''}
51
- },
52
- before: {},
53
- after: {},
54
- error: {}
55
- }
8
+ import { ${className}, ${camelName}Hooks } from './${fileName}.class'
56
9
 
57
10
  // A configure function that registers the service and its hooks via \`app.configure\`
58
11
  export function ${camelName} (app: Application) {
@@ -67,7 +20,7 @@ export function ${camelName} (app: Application) {
67
20
  events: []
68
21
  })
69
22
  // Initialize hooks
70
- app.service('${path}').hooks(hooks)
23
+ app.service('${path}').hooks(${camelName}Hooks)
71
24
  }
72
25
 
73
26
  // Add this service to the service type index
@@ -77,16 +30,17 @@ declare module '${relative}/declarations' {
77
30
  }
78
31
  }
79
32
  `;
80
- const importTemplate = ({ camelName, path }) => `import { ${camelName} } from './${path}'`;
33
+ const importTemplate = ({ camelName, folder, fileName }) => `import { ${camelName} } from './${folder.join('/')}/${fileName}.service'`;
81
34
  const configureTemplate = ({ camelName }) => ` app.configure(${camelName})`;
82
- const toServiceIndex = (0, pinion_1.toFile)(({ lib, language }) => [
35
+ const toServiceIndex = (0, pinion_1.toFile)(({ lib }) => [lib, 'services', `index`]);
36
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
37
+ .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
83
38
  lib,
84
39
  'services',
85
- `index.${language}`
86
- ]);
87
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
88
- .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [lib, 'services', ...folder, fileName])))
89
- .then((0, pinion_1.inject)((0, commons_1.getSource)(importTemplate), (0, pinion_1.prepend)(), toServiceIndex))
90
- .then((0, pinion_1.inject)(configureTemplate, (0, pinion_1.after)('export const services'), toServiceIndex));
40
+ ...folder,
41
+ `${fileName}.service`
42
+ ])))
43
+ .then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.prepend)(), toServiceIndex))
44
+ .then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.after)('export const services'), toServiceIndex));
91
45
  exports.generate = generate;
92
46
  //# sourceMappingURL=service.tpl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/service.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,2CAAuD;AAGvD,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,eAAe,EACf,cAAc,EACU,EAAE,EAAE,CAC5B;EACA,eAAe,IAAI,cAAc,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC,EAAE;oCAClE,QAAQ;;IAExC,SAAS;IACT,SAAS;IACT,SAAS;UACH,QAAQ,IAAI,UAAU;WACrB,SAAS,qBAAqB,QAAQ,IAAI,YAAY;;;;YAK3D,cAAc;IACZ,CAAC,CAAC;2BACiB;IACnB,CAAC,CAAC,EACN,IACA,CAAC,eAAe;IACd,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