@feathersjs/generators 5.0.0-pre.35
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.
- package/CHANGELOG.md +10 -0
- package/LICENSE +22 -0
- package/README.md +23 -0
- package/lib/app/index.d.ts +29 -0
- package/lib/app/index.js +146 -0
- package/lib/app/index.js.map +1 -0
- package/lib/app/index.ts +228 -0
- package/lib/app/static/.gitignore +121 -0
- package/lib/app/templates/app.test.tpl.d.ts +2 -0
- package/lib/app/templates/app.test.tpl.js +49 -0
- package/lib/app/templates/app.test.tpl.js.map +1 -0
- package/lib/app/templates/app.test.tpl.ts +50 -0
- package/lib/app/templates/app.tpl.d.ts +2 -0
- package/lib/app/templates/app.tpl.js +123 -0
- package/lib/app/templates/app.tpl.js.map +1 -0
- package/lib/app/templates/app.tpl.ts +138 -0
- package/lib/app/templates/channels.tpl.d.ts +2 -0
- package/lib/app/templates/channels.tpl.js +50 -0
- package/lib/app/templates/channels.tpl.js.map +1 -0
- package/lib/app/templates/channels.tpl.ts +56 -0
- package/lib/app/templates/client.test.tpl.d.ts +2 -0
- package/lib/app/templates/client.test.tpl.js +27 -0
- package/lib/app/templates/client.test.tpl.js.map +1 -0
- package/lib/app/templates/client.test.tpl.ts +26 -0
- package/lib/app/templates/client.tpl.d.ts +2 -0
- package/lib/app/templates/client.tpl.js +38 -0
- package/lib/app/templates/client.tpl.js.map +1 -0
- package/lib/app/templates/client.tpl.ts +45 -0
- package/lib/app/templates/configuration.tpl.d.ts +2 -0
- package/lib/app/templates/configuration.tpl.js +71 -0
- package/lib/app/templates/configuration.tpl.js.map +1 -0
- package/lib/app/templates/configuration.tpl.ts +82 -0
- package/lib/app/templates/declarations.tpl.d.ts +2 -0
- package/lib/app/templates/declarations.tpl.js +28 -0
- package/lib/app/templates/declarations.tpl.js.map +1 -0
- package/lib/app/templates/declarations.tpl.ts +37 -0
- package/lib/app/templates/index.html.tpl.d.ts +2 -0
- package/lib/app/templates/index.html.tpl.js +45 -0
- package/lib/app/templates/index.html.tpl.js.map +1 -0
- package/lib/app/templates/index.html.tpl.ts +44 -0
- package/lib/app/templates/index.tpl.d.ts +2 -0
- package/lib/app/templates/index.tpl.js +22 -0
- package/lib/app/templates/index.tpl.js.map +1 -0
- package/lib/app/templates/index.tpl.ts +26 -0
- package/lib/app/templates/logger.tpl.d.ts +3 -0
- package/lib/app/templates/logger.tpl.js +45 -0
- package/lib/app/templates/logger.tpl.js.map +1 -0
- package/lib/app/templates/logger.tpl.ts +56 -0
- package/lib/app/templates/package.json.tpl.d.ts +2 -0
- package/lib/app/templates/package.json.tpl.js +58 -0
- package/lib/app/templates/package.json.tpl.js.map +1 -0
- package/lib/app/templates/package.json.tpl.ts +71 -0
- package/lib/app/templates/prettierrc.tpl.d.ts +2 -0
- package/lib/app/templates/prettierrc.tpl.js +11 -0
- package/lib/app/templates/prettierrc.tpl.js.map +1 -0
- package/lib/app/templates/prettierrc.tpl.ts +14 -0
- package/lib/app/templates/readme.md.tpl.d.ts +2 -0
- package/lib/app/templates/readme.md.tpl.js +54 -0
- package/lib/app/templates/readme.md.tpl.js.map +1 -0
- package/lib/app/templates/readme.md.tpl.ts +57 -0
- package/lib/app/templates/services.tpl.d.ts +2 -0
- package/lib/app/templates/services.tpl.js +15 -0
- package/lib/app/templates/services.tpl.js.map +1 -0
- package/lib/app/templates/services.tpl.ts +20 -0
- package/lib/app/templates/tsconfig.json.tpl.d.ts +2 -0
- package/lib/app/templates/tsconfig.json.tpl.js +22 -0
- package/lib/app/templates/tsconfig.json.tpl.js.map +1 -0
- package/lib/app/templates/tsconfig.json.tpl.ts +28 -0
- package/lib/app/templates/validators.tpl.d.ts +2 -0
- package/lib/app/templates/validators.tpl.js +36 -0
- package/lib/app/templates/validators.tpl.js.map +1 -0
- package/lib/app/templates/validators.tpl.ts +40 -0
- package/lib/authentication/index.d.ts +73 -0
- package/lib/authentication/index.js +107 -0
- package/lib/authentication/index.js.map +1 -0
- package/lib/authentication/index.ts +126 -0
- package/lib/authentication/templates/authentication.tpl.d.ts +2 -0
- package/lib/authentication/templates/authentication.tpl.js +40 -0
- package/lib/authentication/templates/authentication.tpl.js.map +1 -0
- package/lib/authentication/templates/authentication.tpl.ts +51 -0
- package/lib/authentication/templates/client.test.tpl.d.ts +2 -0
- package/lib/authentication/templates/client.test.tpl.js +62 -0
- package/lib/authentication/templates/client.test.tpl.js.map +1 -0
- package/lib/authentication/templates/client.test.tpl.ts +74 -0
- package/lib/authentication/templates/config.tpl.d.ts +2 -0
- package/lib/authentication/templates/config.tpl.js +50 -0
- package/lib/authentication/templates/config.tpl.js.map +1 -0
- package/lib/authentication/templates/config.tpl.ts +57 -0
- package/lib/authentication/templates/declarations.tpl.d.ts +2 -0
- package/lib/authentication/templates/declarations.tpl.js +19 -0
- package/lib/authentication/templates/declarations.tpl.js.map +1 -0
- package/lib/authentication/templates/declarations.tpl.ts +34 -0
- package/lib/authentication/templates/knex.tpl.d.ts +2 -0
- package/lib/authentication/templates/knex.tpl.js +45 -0
- package/lib/authentication/templates/knex.tpl.js.map +1 -0
- package/lib/authentication/templates/knex.tpl.ts +62 -0
- package/lib/authentication/templates/schema.json.tpl.d.ts +2 -0
- package/lib/authentication/templates/schema.json.tpl.js +103 -0
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.json.tpl.ts +124 -0
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +3 -0
- package/lib/authentication/templates/schema.typebox.tpl.js +86 -0
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.ts +108 -0
- package/lib/commons.d.ts +150 -0
- package/lib/commons.js +198 -0
- package/lib/commons.js.map +1 -0
- package/lib/commons.ts +284 -0
- package/lib/connection/index.d.ts +55 -0
- package/lib/connection/index.js +88 -0
- package/lib/connection/index.js.map +1 -0
- package/lib/connection/index.ts +123 -0
- package/lib/connection/templates/knex.tpl.d.ts +2 -0
- package/lib/connection/templates/knex.tpl.js +48 -0
- package/lib/connection/templates/knex.tpl.js.map +1 -0
- package/lib/connection/templates/knex.tpl.ts +67 -0
- package/lib/connection/templates/mongodb.tpl.d.ts +2 -0
- package/lib/connection/templates/mongodb.tpl.js +34 -0
- package/lib/connection/templates/mongodb.tpl.js.map +1 -0
- package/lib/connection/templates/mongodb.tpl.ts +40 -0
- package/lib/hook/index.d.ts +22 -0
- package/lib/hook/index.js +43 -0
- package/lib/hook/index.js.map +1 -0
- package/lib/hook/index.ts +47 -0
- package/lib/hook/templates/hook.tpl.d.ts +2 -0
- package/lib/hook/templates/hook.tpl.js +22 -0
- package/lib/hook/templates/hook.tpl.js.map +1 -0
- package/lib/hook/templates/hook.tpl.ts +33 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +37 -0
- package/lib/index.js.map +1 -0
- package/lib/index.ts +8 -0
- package/lib/service/index.d.ts +64 -0
- package/lib/service/index.js +116 -0
- package/lib/service/index.js.map +1 -0
- package/lib/service/index.ts +191 -0
- package/lib/service/templates/client.tpl.d.ts +2 -0
- package/lib/service/templates/client.tpl.js +30 -0
- package/lib/service/templates/client.tpl.js.map +1 -0
- package/lib/service/templates/client.tpl.ts +56 -0
- package/lib/service/templates/schema.json.tpl.d.ts +2 -0
- package/lib/service/templates/schema.json.tpl.js +83 -0
- package/lib/service/templates/schema.json.tpl.js.map +1 -0
- package/lib/service/templates/schema.json.tpl.ts +98 -0
- package/lib/service/templates/schema.typebox.tpl.d.ts +2 -0
- package/lib/service/templates/schema.typebox.tpl.js +61 -0
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/service/templates/schema.typebox.tpl.ts +76 -0
- package/lib/service/templates/service.tpl.d.ts +3 -0
- package/lib/service/templates/service.tpl.js +112 -0
- package/lib/service/templates/service.tpl.js.map +1 -0
- package/lib/service/templates/service.tpl.ts +152 -0
- package/lib/service/templates/test.tpl.d.ts +2 -0
- package/lib/service/templates/test.tpl.js +25 -0
- package/lib/service/templates/test.tpl.js.map +1 -0
- package/lib/service/templates/test.tpl.ts +33 -0
- package/lib/service/type/custom.tpl.d.ts +3 -0
- package/lib/service/type/custom.tpl.js +98 -0
- package/lib/service/type/custom.tpl.js.map +1 -0
- package/lib/service/type/custom.tpl.ts +109 -0
- package/lib/service/type/knex.tpl.d.ts +3 -0
- package/lib/service/type/knex.tpl.js +71 -0
- package/lib/service/type/knex.tpl.js.map +1 -0
- package/lib/service/type/knex.tpl.ts +92 -0
- package/lib/service/type/mongodb.tpl.d.ts +3 -0
- package/lib/service/type/mongodb.tpl.js +50 -0
- package/lib/service/type/mongodb.tpl.js.map +1 -0
- package/lib/service/type/mongodb.tpl.ts +62 -0
- package/package.json +89 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
+
const template = ({ name, description, language, database }) => /* md */ `# ${name}
|
|
6
|
+
|
|
7
|
+
> ${description}
|
|
8
|
+
|
|
9
|
+
## About
|
|
10
|
+
|
|
11
|
+
This project uses [Feathers](http://feathersjs.com). An open source framework for building APIs and real-time applications.
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
1. Make sure you have [NodeJS](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed.
|
|
16
|
+
2. Install your dependencies
|
|
17
|
+
|
|
18
|
+
\`\`\`
|
|
19
|
+
cd path/to/${name}
|
|
20
|
+
npm install
|
|
21
|
+
\`\`\`
|
|
22
|
+
|
|
23
|
+
3. Start your app
|
|
24
|
+
|
|
25
|
+
\`\`\`${language === 'ts'
|
|
26
|
+
? `
|
|
27
|
+
npm run compile # Compile TypeScript source`
|
|
28
|
+
: ''}${database !== 'mongodb'
|
|
29
|
+
? `
|
|
30
|
+
npm run migrate # Run migrations to set up the database`
|
|
31
|
+
: ''}
|
|
32
|
+
npm start
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
## Testing
|
|
36
|
+
|
|
37
|
+
Run \`npm test\` and all your tests in the \`test/\` directory will be run.
|
|
38
|
+
|
|
39
|
+
## Scaffolding
|
|
40
|
+
|
|
41
|
+
This app comes with a powerful command line interface for Feathers. Here are a few things it can do:
|
|
42
|
+
|
|
43
|
+
\`\`\`
|
|
44
|
+
$ npx feathers help # Show all commands
|
|
45
|
+
$ npx feathers generate service # Generate a new Service
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
## Help
|
|
49
|
+
|
|
50
|
+
For more information on all the things you can do with Feathers visit [docs.feathersjs.com](http://docs.feathersjs.com).
|
|
51
|
+
`;
|
|
52
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.renderTemplate)(template, (0, pinion_1.toFile)('readme.md')));
|
|
53
|
+
exports.generate = generate;
|
|
54
|
+
//# sourceMappingURL=readme.md.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readme.md.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/readme.md.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AAGtE,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,IAAI;;IAEnG,WAAW;;;;;;;;;;;;iBAYE,IAAI;;;;;;YAOf,QAAQ,KAAK,IAAI;IACf,CAAC,CAAC;gDACsC;IACxC,CAAC,CAAC,EACN,GACF,QAAQ,KAAK,SAAS;IACpB,CAAC,CAAC;4DACsD;IACxD,CAAC,CAAC,EACN;;;;;;;;;;;;;;;;;;;;CAoBC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,uBAAc,EAAC,QAAQ,EAAE,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AADvD,QAAA,QAAQ,YAC+C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { generator, renderTemplate, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { AppGeneratorContext } from '../index'
|
|
3
|
+
|
|
4
|
+
const template = ({ name, description, language, database }: AppGeneratorContext) => /* md */ `# ${name}
|
|
5
|
+
|
|
6
|
+
> ${description}
|
|
7
|
+
|
|
8
|
+
## About
|
|
9
|
+
|
|
10
|
+
This project uses [Feathers](http://feathersjs.com). An open source framework for building APIs and real-time applications.
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
1. Make sure you have [NodeJS](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed.
|
|
15
|
+
2. Install your dependencies
|
|
16
|
+
|
|
17
|
+
\`\`\`
|
|
18
|
+
cd path/to/${name}
|
|
19
|
+
npm install
|
|
20
|
+
\`\`\`
|
|
21
|
+
|
|
22
|
+
3. Start your app
|
|
23
|
+
|
|
24
|
+
\`\`\`${
|
|
25
|
+
language === 'ts'
|
|
26
|
+
? `
|
|
27
|
+
npm run compile # Compile TypeScript source`
|
|
28
|
+
: ''
|
|
29
|
+
}${
|
|
30
|
+
database !== 'mongodb'
|
|
31
|
+
? `
|
|
32
|
+
npm run migrate # Run migrations to set up the database`
|
|
33
|
+
: ''
|
|
34
|
+
}
|
|
35
|
+
npm start
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
## Testing
|
|
39
|
+
|
|
40
|
+
Run \`npm test\` and all your tests in the \`test/\` directory will be run.
|
|
41
|
+
|
|
42
|
+
## Scaffolding
|
|
43
|
+
|
|
44
|
+
This app comes with a powerful command line interface for Feathers. Here are a few things it can do:
|
|
45
|
+
|
|
46
|
+
\`\`\`
|
|
47
|
+
$ npx feathers help # Show all commands
|
|
48
|
+
$ npx feathers generate service # Generate a new Service
|
|
49
|
+
\`\`\`
|
|
50
|
+
|
|
51
|
+
## Help
|
|
52
|
+
|
|
53
|
+
For more information on all the things you can do with Feathers visit [docs.feathersjs.com](http://docs.feathersjs.com).
|
|
54
|
+
`
|
|
55
|
+
|
|
56
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
57
|
+
generator(ctx).then(renderTemplate(template, toFile('readme.md')))
|
|
@@ -0,0 +1,15 @@
|
|
|
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 = ({}) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/application.html#configure-functions
|
|
7
|
+
import type { Application } from '../declarations'
|
|
8
|
+
|
|
9
|
+
export const services = (app: Application) => {
|
|
10
|
+
// All services will be registered here
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'services', 'index')));
|
|
14
|
+
exports.generate = generate;
|
|
15
|
+
//# sourceMappingURL=services.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/services.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GACZ,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;CAMvC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CACnE,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template =
|
|
6
|
+
({}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/application.html#configure-functions
|
|
7
|
+
import type { Application } from '../declarations'
|
|
8
|
+
|
|
9
|
+
export const services = (app: Application) => {
|
|
10
|
+
// All services will be registered here
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
15
|
+
generator(ctx).then(
|
|
16
|
+
renderSource(
|
|
17
|
+
template,
|
|
18
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'services', 'index')
|
|
19
|
+
)
|
|
20
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.writeJSON)(({ lib }) => ({
|
|
6
|
+
'ts-node': {
|
|
7
|
+
files: true
|
|
8
|
+
},
|
|
9
|
+
compilerOptions: {
|
|
10
|
+
target: 'es2020',
|
|
11
|
+
module: 'commonjs',
|
|
12
|
+
outDir: './lib',
|
|
13
|
+
rootDir: `./${lib}`,
|
|
14
|
+
declaration: true,
|
|
15
|
+
strict: true,
|
|
16
|
+
esModuleInterop: true
|
|
17
|
+
},
|
|
18
|
+
include: [lib],
|
|
19
|
+
exclude: ['test']
|
|
20
|
+
}), (0, pinion_1.toFile)('tsconfig.json'))));
|
|
21
|
+
exports.generate = generate;
|
|
22
|
+
//# sourceMappingURL=tsconfig.json.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.json.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/tsconfig.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAuE;AAGhE,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,kBAAS,EACP,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE;QACT,KAAK,EAAE,IAAI;KACZ;IACD,eAAe,EAAE;QACf,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,KAAK,GAAG,EAAE;QACnB,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,IAAI;QACZ,eAAe,EAAE,IAAI;KACtB;IACD,OAAO,EAAE,CAAC,GAAG,CAAC;IACd,OAAO,EAAE,CAAC,MAAM,CAAC;CAClB,CAAC,EACF,IAAA,eAAM,EAAC,eAAe,CAAC,CACxB,CACF,CACF,CAAA;AAxBU,QAAA,QAAQ,YAwBlB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { generator, toFile, when, writeJSON } from '@feathershq/pinion'
|
|
2
|
+
import { AppGeneratorContext } from '../index'
|
|
3
|
+
|
|
4
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
5
|
+
generator(ctx).then(
|
|
6
|
+
when<AppGeneratorContext>(
|
|
7
|
+
(ctx) => ctx.language === 'ts',
|
|
8
|
+
writeJSON<AppGeneratorContext>(
|
|
9
|
+
({ lib }) => ({
|
|
10
|
+
'ts-node': {
|
|
11
|
+
files: true
|
|
12
|
+
},
|
|
13
|
+
compilerOptions: {
|
|
14
|
+
target: 'es2020',
|
|
15
|
+
module: 'commonjs',
|
|
16
|
+
outDir: './lib',
|
|
17
|
+
rootDir: `./${lib}`,
|
|
18
|
+
declaration: true,
|
|
19
|
+
strict: true,
|
|
20
|
+
esModuleInterop: true
|
|
21
|
+
},
|
|
22
|
+
include: [lib],
|
|
23
|
+
exclude: ['test']
|
|
24
|
+
}),
|
|
25
|
+
toFile('tsconfig.json')
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
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 validatorTemplate = /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/validators.html
|
|
7
|
+
import { Ajv, addFormats } from '@feathersjs/schema'
|
|
8
|
+
import type { FormatsPluginOptions } from '@feathersjs/schema'
|
|
9
|
+
|
|
10
|
+
const formats: FormatsPluginOptions = [
|
|
11
|
+
'date-time',
|
|
12
|
+
'time',
|
|
13
|
+
'date',
|
|
14
|
+
'email',
|
|
15
|
+
'hostname',
|
|
16
|
+
'ipv4',
|
|
17
|
+
'ipv6',
|
|
18
|
+
'uri',
|
|
19
|
+
'uri-reference',
|
|
20
|
+
'uuid',
|
|
21
|
+
'uri-template',
|
|
22
|
+
'json-pointer',
|
|
23
|
+
'relative-json-pointer',
|
|
24
|
+
'regex'
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
export const dataValidator: Ajv = addFormats(new Ajv({}), formats)
|
|
28
|
+
|
|
29
|
+
export const queryValidator: Ajv = addFormats(new Ajv({
|
|
30
|
+
coerceTypes: true,
|
|
31
|
+
removeAdditional: true
|
|
32
|
+
}), formats)
|
|
33
|
+
`;
|
|
34
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(validatorTemplate, (0, pinion_1.toFile)(({ lib }) => lib, 'validators')));
|
|
35
|
+
exports.generate = generate;
|
|
36
|
+
//# sourceMappingURL=validators.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/validators.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BlC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,YAAY,CAAC,CAC5D,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const validatorTemplate = /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/validators.html
|
|
6
|
+
import { Ajv, addFormats } from '@feathersjs/schema'
|
|
7
|
+
import type { FormatsPluginOptions } from '@feathersjs/schema'
|
|
8
|
+
|
|
9
|
+
const formats: FormatsPluginOptions = [
|
|
10
|
+
'date-time',
|
|
11
|
+
'time',
|
|
12
|
+
'date',
|
|
13
|
+
'email',
|
|
14
|
+
'hostname',
|
|
15
|
+
'ipv4',
|
|
16
|
+
'ipv6',
|
|
17
|
+
'uri',
|
|
18
|
+
'uri-reference',
|
|
19
|
+
'uuid',
|
|
20
|
+
'uri-template',
|
|
21
|
+
'json-pointer',
|
|
22
|
+
'relative-json-pointer',
|
|
23
|
+
'regex'
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
export const dataValidator: Ajv = addFormats(new Ajv({}), formats)
|
|
27
|
+
|
|
28
|
+
export const queryValidator: Ajv = addFormats(new Ajv({
|
|
29
|
+
coerceTypes: true,
|
|
30
|
+
removeAdditional: true
|
|
31
|
+
}), formats)
|
|
32
|
+
`
|
|
33
|
+
|
|
34
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
35
|
+
generator(ctx).then(
|
|
36
|
+
renderSource(
|
|
37
|
+
validatorTemplate,
|
|
38
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'validators')
|
|
39
|
+
)
|
|
40
|
+
)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FeathersBaseContext } from '../commons';
|
|
2
|
+
import { ServiceGeneratorContext } from '../service/index';
|
|
3
|
+
export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
|
|
4
|
+
service: string;
|
|
5
|
+
entity: string;
|
|
6
|
+
authStrategies: string[];
|
|
7
|
+
dependencies: string[];
|
|
8
|
+
}
|
|
9
|
+
export type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>;
|
|
10
|
+
export declare const localTemplate: (authStrategies: string[], content: string) => string;
|
|
11
|
+
export declare const oauthTemplate: (authStrategies: string[], content: string) => string;
|
|
12
|
+
export declare const prompts: (ctx: AuthenticationGeneratorArguments) => ({
|
|
13
|
+
type: string;
|
|
14
|
+
name: string;
|
|
15
|
+
when: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
suffix: string;
|
|
18
|
+
choices: ({
|
|
19
|
+
name: string;
|
|
20
|
+
value: string;
|
|
21
|
+
checked: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
name: string;
|
|
24
|
+
value: string;
|
|
25
|
+
checked?: undefined;
|
|
26
|
+
})[];
|
|
27
|
+
default?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
when: boolean;
|
|
32
|
+
message: string;
|
|
33
|
+
default: string;
|
|
34
|
+
suffix?: undefined;
|
|
35
|
+
choices?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
name: string;
|
|
38
|
+
type: string;
|
|
39
|
+
when: boolean;
|
|
40
|
+
message: string;
|
|
41
|
+
suffix: string;
|
|
42
|
+
default: string;
|
|
43
|
+
choices?: undefined;
|
|
44
|
+
})[];
|
|
45
|
+
export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promise<{
|
|
46
|
+
dependencies: string[];
|
|
47
|
+
name: string;
|
|
48
|
+
path: string;
|
|
49
|
+
folder: string[];
|
|
50
|
+
camelName: string;
|
|
51
|
+
upperName: string;
|
|
52
|
+
className: string;
|
|
53
|
+
kebabName: string;
|
|
54
|
+
fileName: string;
|
|
55
|
+
kebabPath: string;
|
|
56
|
+
relative: string;
|
|
57
|
+
type: "mongodb" | "knex" | "custom";
|
|
58
|
+
schema: false | "typebox" | "json";
|
|
59
|
+
authentication: boolean;
|
|
60
|
+
isEntityService?: boolean;
|
|
61
|
+
feathers: import("../commons").FeathersAppInfo;
|
|
62
|
+
pkg: import("../commons").AppPackageJson;
|
|
63
|
+
lib: string;
|
|
64
|
+
test: string;
|
|
65
|
+
language: "ts" | "js";
|
|
66
|
+
dependencyVersions?: import("../commons").DependencyVersions;
|
|
67
|
+
cwd: string;
|
|
68
|
+
_?: (string | number)[];
|
|
69
|
+
pinion: import("@feathershq/pinion").Configuration;
|
|
70
|
+
service: string;
|
|
71
|
+
entity: string;
|
|
72
|
+
authStrategies: string[];
|
|
73
|
+
}>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generate = exports.prompts = exports.oauthTemplate = exports.localTemplate = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
9
|
+
const commons_1 = require("../commons");
|
|
10
|
+
const index_1 = require("../service/index");
|
|
11
|
+
const localTemplate = (authStrategies, content) => authStrategies.includes('local') ? content : '';
|
|
12
|
+
exports.localTemplate = localTemplate;
|
|
13
|
+
const oauthTemplate = (authStrategies, content) => authStrategies.filter((s) => s !== 'local').length > 0 ? content : '';
|
|
14
|
+
exports.oauthTemplate = oauthTemplate;
|
|
15
|
+
const prompts = (ctx) => [
|
|
16
|
+
{
|
|
17
|
+
type: 'checkbox',
|
|
18
|
+
name: 'authStrategies',
|
|
19
|
+
when: !ctx.authStrategies,
|
|
20
|
+
message: 'Which authentication methods do you want to use?',
|
|
21
|
+
suffix: chalk_1.default.grey(' Other methods and providers can be added at any time.'),
|
|
22
|
+
choices: [
|
|
23
|
+
{
|
|
24
|
+
name: 'Email + Password',
|
|
25
|
+
value: 'local',
|
|
26
|
+
checked: true
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Google',
|
|
30
|
+
value: 'google'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'Facebook',
|
|
34
|
+
value: 'facebook'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'Twitter',
|
|
38
|
+
value: 'twitter'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'GitHub',
|
|
42
|
+
value: 'github'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'Auth0',
|
|
46
|
+
value: 'auth0'
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'service',
|
|
52
|
+
type: 'input',
|
|
53
|
+
when: !ctx.service,
|
|
54
|
+
message: 'What is your authentication service name?',
|
|
55
|
+
default: 'user'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'path',
|
|
59
|
+
type: 'input',
|
|
60
|
+
when: !ctx.path,
|
|
61
|
+
message: 'What path should the service be registered on?',
|
|
62
|
+
default: 'users'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'entity',
|
|
66
|
+
type: 'input',
|
|
67
|
+
when: !ctx.entity,
|
|
68
|
+
message: 'What is your authenticated entity name?',
|
|
69
|
+
suffix: chalk_1.default.grey(' Will be available in params (e.g. params.user)'),
|
|
70
|
+
default: 'user'
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
exports.prompts = prompts;
|
|
74
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
75
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
76
|
+
.then((0, commons_1.checkPreconditions)())
|
|
77
|
+
.then((0, pinion_1.prompt)(exports.prompts))
|
|
78
|
+
.then(async (ctx) => {
|
|
79
|
+
var _a;
|
|
80
|
+
const serviceContext = await (0, index_1.generate)({
|
|
81
|
+
...ctx,
|
|
82
|
+
name: ctx.service,
|
|
83
|
+
isEntityService: true,
|
|
84
|
+
type: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database)
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
...ctx,
|
|
88
|
+
...serviceContext
|
|
89
|
+
};
|
|
90
|
+
})
|
|
91
|
+
.then((0, pinion_1.runGenerators)(__dirname, 'templates'))
|
|
92
|
+
.then((ctx) => {
|
|
93
|
+
const dependencies = [];
|
|
94
|
+
dependencies.push('@feathersjs/authentication-oauth');
|
|
95
|
+
if (ctx.authStrategies.includes('local')) {
|
|
96
|
+
dependencies.push('@feathersjs/authentication-local');
|
|
97
|
+
}
|
|
98
|
+
if (ctx.dependencies) {
|
|
99
|
+
return {
|
|
100
|
+
...ctx,
|
|
101
|
+
dependencies: [...ctx.dependencies, ...dependencies]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
|
|
105
|
+
});
|
|
106
|
+
exports.generate = generate;
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { generator, runGenerators, prompt, install } from '@feathershq/pinion'
|
|
3
|
+
import {
|
|
4
|
+
addVersions,
|
|
5
|
+
checkPreconditions,
|
|
6
|
+
FeathersBaseContext,
|
|
7
|
+
getDatabaseAdapter,
|
|
8
|
+
initializeBaseContext
|
|
9
|
+
} from '../commons'
|
|
10
|
+
import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index'
|
|
11
|
+
|
|
12
|
+
export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
|
|
13
|
+
service: string
|
|
14
|
+
entity: string
|
|
15
|
+
authStrategies: string[]
|
|
16
|
+
dependencies: string[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type AuthenticationGeneratorArguments = FeathersBaseContext &
|
|
20
|
+
Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>
|
|
21
|
+
|
|
22
|
+
export const localTemplate = (authStrategies: string[], content: string) =>
|
|
23
|
+
authStrategies.includes('local') ? content : ''
|
|
24
|
+
export const oauthTemplate = (authStrategies: string[], content: string) =>
|
|
25
|
+
authStrategies.filter((s) => s !== 'local').length > 0 ? content : ''
|
|
26
|
+
|
|
27
|
+
export const prompts = (ctx: AuthenticationGeneratorArguments) => [
|
|
28
|
+
{
|
|
29
|
+
type: 'checkbox',
|
|
30
|
+
name: 'authStrategies',
|
|
31
|
+
when: !ctx.authStrategies,
|
|
32
|
+
message: 'Which authentication methods do you want to use?',
|
|
33
|
+
suffix: chalk.grey(' Other methods and providers can be added at any time.'),
|
|
34
|
+
choices: [
|
|
35
|
+
{
|
|
36
|
+
name: 'Email + Password',
|
|
37
|
+
value: 'local',
|
|
38
|
+
checked: true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'Google',
|
|
42
|
+
value: 'google'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'Facebook',
|
|
46
|
+
value: 'facebook'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'Twitter',
|
|
50
|
+
value: 'twitter'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'GitHub',
|
|
54
|
+
value: 'github'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Auth0',
|
|
58
|
+
value: 'auth0'
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'service',
|
|
64
|
+
type: 'input',
|
|
65
|
+
when: !ctx.service,
|
|
66
|
+
message: 'What is your authentication service name?',
|
|
67
|
+
default: 'user'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'path',
|
|
71
|
+
type: 'input',
|
|
72
|
+
when: !ctx.path,
|
|
73
|
+
message: 'What path should the service be registered on?',
|
|
74
|
+
default: 'users'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'entity',
|
|
78
|
+
type: 'input',
|
|
79
|
+
when: !ctx.entity,
|
|
80
|
+
message: 'What is your authenticated entity name?',
|
|
81
|
+
suffix: chalk.grey(' Will be available in params (e.g. params.user)'),
|
|
82
|
+
default: 'user'
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
export const generate = (ctx: AuthenticationGeneratorArguments) =>
|
|
87
|
+
generator(ctx)
|
|
88
|
+
.then(initializeBaseContext())
|
|
89
|
+
.then(checkPreconditions())
|
|
90
|
+
.then(prompt<AuthenticationGeneratorArguments, AuthenticationGeneratorContext>(prompts))
|
|
91
|
+
.then(async (ctx) => {
|
|
92
|
+
const serviceContext = await serviceGenerator({
|
|
93
|
+
...ctx,
|
|
94
|
+
name: ctx.service,
|
|
95
|
+
isEntityService: true,
|
|
96
|
+
type: getDatabaseAdapter(ctx.feathers?.database)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
...ctx,
|
|
101
|
+
...serviceContext
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.then(runGenerators(__dirname, 'templates'))
|
|
105
|
+
.then((ctx) => {
|
|
106
|
+
const dependencies: string[] = []
|
|
107
|
+
|
|
108
|
+
dependencies.push('@feathersjs/authentication-oauth')
|
|
109
|
+
|
|
110
|
+
if (ctx.authStrategies.includes('local')) {
|
|
111
|
+
dependencies.push('@feathersjs/authentication-local')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (ctx.dependencies) {
|
|
115
|
+
return {
|
|
116
|
+
...ctx,
|
|
117
|
+
dependencies: [...ctx.dependencies, ...dependencies]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return install<AuthenticationGeneratorContext>(
|
|
122
|
+
addVersions(dependencies, ctx.dependencyVersions),
|
|
123
|
+
false,
|
|
124
|
+
ctx.feathers.packager
|
|
125
|
+
)(ctx)
|
|
126
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
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 = ({ authStrategies }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/authentication.html
|
|
8
|
+
import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
9
|
+
${(0, index_1.localTemplate)(authStrategies, `import { LocalStrategy } from '@feathersjs/authentication-local'`)}
|
|
10
|
+
${(0, index_1.oauthTemplate)(authStrategies, `import { oauth, OAuthStrategy } from '@feathersjs/authentication-oauth'`)}
|
|
11
|
+
|
|
12
|
+
import type { Application } from './declarations'
|
|
13
|
+
|
|
14
|
+
declare module './declarations' {
|
|
15
|
+
interface ServiceTypes {
|
|
16
|
+
'authentication': AuthenticationService
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const authentication = (app: Application) => {
|
|
21
|
+
const authentication = new AuthenticationService(app)
|
|
22
|
+
|
|
23
|
+
authentication.register('jwt', new JWTStrategy())
|
|
24
|
+
${authStrategies
|
|
25
|
+
.map((strategy) => ` authentication.register('${strategy}', ${strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()`})`)
|
|
26
|
+
.join('\n')}
|
|
27
|
+
|
|
28
|
+
app.use('authentication', authentication)
|
|
29
|
+
${(0, index_1.oauthTemplate)(authStrategies, `app.configure(oauth())`)}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
const importTemplate = "import { authentication } from './authentication'";
|
|
33
|
+
const configureTemplate = 'app.configure(authentication)';
|
|
34
|
+
const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
|
|
35
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
36
|
+
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'authentication')))
|
|
37
|
+
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
38
|
+
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
|
|
39
|
+
exports.generate = generate;
|
|
40
|
+
//# sourceMappingURL=authentication.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAC1D,oCAAuF;AAEvF,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;EAE7C,IAAA,qBAAa,EAAC,cAAc,EAAE,kEAAkE,CAAC;EACjG,IAAA,qBAAa,EAAC,cAAc,EAAE,yEAAyE,CAAC;;;;;;;;;;;;;;IActG,cAAc;KACb,GAAG,CACF,CAAC,QAAQ,EAAE,EAAE,CACX,8BAA8B,QAAQ,MACpC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBACjD,GAAG,CACN;KACA,IAAI,CAAC,IAAI,CAAC;;;IAGX,IAAA,qBAAa,EAAC,cAAc,EAAE,wBAAwB,CAAC;;CAE1D,CAAA;AAED,MAAM,cAAc,GAAG,mDAAmD,CAAA;AAC1E,MAAM,iBAAiB,GAAG,+BAA+B,CAAA;AACzD,MAAM,SAAS,GAAG,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAE5E,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAT3E,QAAA,QAAQ,YASmE"}
|