@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,112 @@
|
|
|
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 template = ({ camelName, authentication, isEntityService, path, className, relative, schema, fileName }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.html
|
|
7
|
+
${authentication || isEntityService ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
8
|
+
${schema
|
|
9
|
+
? `
|
|
10
|
+
import { hooks as schemaHooks } from '@feathersjs/schema'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
${camelName}DataValidator,
|
|
14
|
+
${camelName}PatchValidator,
|
|
15
|
+
${camelName}QueryValidator,
|
|
16
|
+
${camelName}Resolver,
|
|
17
|
+
${camelName}ExternalResolver,
|
|
18
|
+
${camelName}DataResolver,
|
|
19
|
+
${camelName}PatchResolver,
|
|
20
|
+
${camelName}QueryResolver
|
|
21
|
+
} from './${fileName}.schema'
|
|
22
|
+
`
|
|
23
|
+
: ''}
|
|
24
|
+
|
|
25
|
+
import type { Application } from '${relative}/declarations'
|
|
26
|
+
import { ${className}, getOptions } from './${fileName}.class'
|
|
27
|
+
|
|
28
|
+
export * from './${fileName}.class'
|
|
29
|
+
${schema ? `export * from './${fileName}.schema'` : ''}
|
|
30
|
+
|
|
31
|
+
// A configure function that registers the service and its hooks via \`app.configure\`
|
|
32
|
+
export const ${camelName} = (app: Application) => {
|
|
33
|
+
// Register our service on the Feathers application
|
|
34
|
+
app.use('${path}', new ${className}(getOptions(app)), {
|
|
35
|
+
// A list of all methods this service exposes externally
|
|
36
|
+
methods: ['find', 'get', 'create', 'patch', 'remove'],
|
|
37
|
+
// You can add additional custom events to be sent to clients here
|
|
38
|
+
events: []
|
|
39
|
+
})
|
|
40
|
+
// Initialize hooks
|
|
41
|
+
app.service('${path}').hooks({
|
|
42
|
+
around: {
|
|
43
|
+
all: [${authentication
|
|
44
|
+
? `
|
|
45
|
+
authenticate('jwt'),`
|
|
46
|
+
: ''} ${schema
|
|
47
|
+
? `
|
|
48
|
+
schemaHooks.resolveExternal(${camelName}ExternalResolver),
|
|
49
|
+
schemaHooks.resolveResult(${camelName}Resolver),`
|
|
50
|
+
: ''}
|
|
51
|
+
],${isEntityService
|
|
52
|
+
? `
|
|
53
|
+
find: [authenticate('jwt')],
|
|
54
|
+
get: [authenticate('jwt')],
|
|
55
|
+
create: [],
|
|
56
|
+
update: [authenticate('jwt')],
|
|
57
|
+
patch: [authenticate('jwt')],
|
|
58
|
+
remove: [authenticate('jwt')]`
|
|
59
|
+
: ''}
|
|
60
|
+
},
|
|
61
|
+
before: {
|
|
62
|
+
all: [${schema
|
|
63
|
+
? `
|
|
64
|
+
schemaHooks.validateQuery(${camelName}QueryValidator),
|
|
65
|
+
schemaHooks.resolveQuery(${camelName}QueryResolver)
|
|
66
|
+
`
|
|
67
|
+
: ''}],
|
|
68
|
+
find: [],
|
|
69
|
+
get: [],
|
|
70
|
+
create: [${schema
|
|
71
|
+
? `
|
|
72
|
+
schemaHooks.validateData(${camelName}DataValidator),
|
|
73
|
+
schemaHooks.resolveData(${camelName}DataResolver)
|
|
74
|
+
`
|
|
75
|
+
: ''}],
|
|
76
|
+
patch: [${schema
|
|
77
|
+
? `
|
|
78
|
+
schemaHooks.validateData(${camelName}PatchValidator),
|
|
79
|
+
schemaHooks.resolveData(${camelName}PatchResolver)
|
|
80
|
+
`
|
|
81
|
+
: ''}],
|
|
82
|
+
remove: []
|
|
83
|
+
},
|
|
84
|
+
after: {
|
|
85
|
+
all: []
|
|
86
|
+
},
|
|
87
|
+
error: {
|
|
88
|
+
all: []
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Add this service to the service type index
|
|
94
|
+
declare module '${relative}/declarations' {
|
|
95
|
+
interface ServiceTypes {
|
|
96
|
+
'${path}': ${className}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
exports.template = template;
|
|
101
|
+
const toServiceIndex = (0, pinion_1.toFile)(({ lib }) => [lib, 'services', `index`]);
|
|
102
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
103
|
+
.then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, fileName, folder }) => [
|
|
104
|
+
lib,
|
|
105
|
+
'services',
|
|
106
|
+
...folder,
|
|
107
|
+
`${fileName}`
|
|
108
|
+
])))
|
|
109
|
+
.then((0, commons_1.injectSource)(({ camelName, folder, fileName }) => `import { ${camelName} } from './${folder.join('/')}/${fileName}'`, (0, pinion_1.prepend)(), toServiceIndex))
|
|
110
|
+
.then((0, commons_1.injectSource)(({ camelName }) => ` app.configure(${camelName})`, (0, pinion_1.after)('export const services'), toServiceIndex));
|
|
111
|
+
exports.generate = generate;
|
|
112
|
+
//# sourceMappingURL=service.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/service.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AACtE,2CAA0D;AAGnD,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,cAAc,EACd,eAAe,EACf,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;EACtC,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC,EAAE;EAEpG,MAAM;IACJ,CAAC,CAAC;;;;IAIF,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;CACnB;IACG,CAAC,CAAC,EACN;;oCAEoC,QAAQ;WACjC,SAAS,0BAA0B,QAAQ;;mBAEnC,QAAQ;EACzB,MAAM,CAAC,CAAC,CAAC,oBAAoB,QAAQ,UAAU,CAAC,CAAC,CAAC,EAAE;;;eAGvC,SAAS;;aAEX,IAAI,UAAU,SAAS;;;;;;;iBAOnB,IAAI;;cAGb,cAAc;IACZ,CAAC,CAAC;6BACiB;IACnB,CAAC,CAAC,EACN,IACJ,MAAM;IACJ,CAAC,CAAC;sCACgC,SAAS;oCACX,SAAS,YAAY;IACrD,CAAC,CAAC,EACN;UAEQ,eAAe;IACb,CAAC,CAAC;;;;;;oCAMwB;IAC1B,CAAC,CAAC,EACN;;;cAIE,MAAM;IACJ,CAAC,CAAC;oCACwB,SAAS;mCACV,SAAS;OACrC;IACG,CAAC,CAAC,EACN;;;iBAIE,MAAM;IACJ,CAAC,CAAC;mCACuB,SAAS;kCACV,SAAS;OACpC;IACG,CAAC,CAAC,EACN;gBAEE,MAAM;IACJ,CAAC,CAAC;mCACuB,SAAS;kCACV,SAAS;OACpC;IACG,CAAC,CAAC,EACN;;;;;;;;;;;;;kBAaY,QAAQ;;OAEnB,IAAI,MAAM,SAAS;;;CAGzB,CAAA;AApHY,QAAA,QAAQ,YAoHpB;AAED,MAAM,cAAc,GAAG,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAA2B,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;AAExF,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAA2B,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,EAAE;CACd,CAAC,CACH,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAClC,YAAY,SAAS,cAAc,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,GAAG,EACpE,IAAA,gBAAO,GAAE,EACT,cAAc,CACf,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,mBAAmB,SAAS,GAAG,EAClD,IAAA,cAAK,EAAC,uBAAuB,CAAC,EAC9B,cAAc,CACf,CACF,CAAA;AA3BQ,QAAA,QAAQ,YA2BhB"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { generator, toFile, after, prepend } from '@feathershq/pinion'
|
|
2
|
+
import { injectSource, renderSource } from '../../commons'
|
|
3
|
+
import { ServiceGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
export const template = ({
|
|
6
|
+
camelName,
|
|
7
|
+
authentication,
|
|
8
|
+
isEntityService,
|
|
9
|
+
path,
|
|
10
|
+
className,
|
|
11
|
+
relative,
|
|
12
|
+
schema,
|
|
13
|
+
fileName
|
|
14
|
+
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.html
|
|
15
|
+
${authentication || isEntityService ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
16
|
+
${
|
|
17
|
+
schema
|
|
18
|
+
? `
|
|
19
|
+
import { hooks as schemaHooks } from '@feathersjs/schema'
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
${camelName}DataValidator,
|
|
23
|
+
${camelName}PatchValidator,
|
|
24
|
+
${camelName}QueryValidator,
|
|
25
|
+
${camelName}Resolver,
|
|
26
|
+
${camelName}ExternalResolver,
|
|
27
|
+
${camelName}DataResolver,
|
|
28
|
+
${camelName}PatchResolver,
|
|
29
|
+
${camelName}QueryResolver
|
|
30
|
+
} from './${fileName}.schema'
|
|
31
|
+
`
|
|
32
|
+
: ''
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
import type { Application } from '${relative}/declarations'
|
|
36
|
+
import { ${className}, getOptions } from './${fileName}.class'
|
|
37
|
+
|
|
38
|
+
export * from './${fileName}.class'
|
|
39
|
+
${schema ? `export * from './${fileName}.schema'` : ''}
|
|
40
|
+
|
|
41
|
+
// A configure function that registers the service and its hooks via \`app.configure\`
|
|
42
|
+
export const ${camelName} = (app: Application) => {
|
|
43
|
+
// Register our service on the Feathers application
|
|
44
|
+
app.use('${path}', new ${className}(getOptions(app)), {
|
|
45
|
+
// A list of all methods this service exposes externally
|
|
46
|
+
methods: ['find', 'get', 'create', 'patch', 'remove'],
|
|
47
|
+
// You can add additional custom events to be sent to clients here
|
|
48
|
+
events: []
|
|
49
|
+
})
|
|
50
|
+
// Initialize hooks
|
|
51
|
+
app.service('${path}').hooks({
|
|
52
|
+
around: {
|
|
53
|
+
all: [${
|
|
54
|
+
authentication
|
|
55
|
+
? `
|
|
56
|
+
authenticate('jwt'),`
|
|
57
|
+
: ''
|
|
58
|
+
} ${
|
|
59
|
+
schema
|
|
60
|
+
? `
|
|
61
|
+
schemaHooks.resolveExternal(${camelName}ExternalResolver),
|
|
62
|
+
schemaHooks.resolveResult(${camelName}Resolver),`
|
|
63
|
+
: ''
|
|
64
|
+
}
|
|
65
|
+
],${
|
|
66
|
+
isEntityService
|
|
67
|
+
? `
|
|
68
|
+
find: [authenticate('jwt')],
|
|
69
|
+
get: [authenticate('jwt')],
|
|
70
|
+
create: [],
|
|
71
|
+
update: [authenticate('jwt')],
|
|
72
|
+
patch: [authenticate('jwt')],
|
|
73
|
+
remove: [authenticate('jwt')]`
|
|
74
|
+
: ''
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
before: {
|
|
78
|
+
all: [${
|
|
79
|
+
schema
|
|
80
|
+
? `
|
|
81
|
+
schemaHooks.validateQuery(${camelName}QueryValidator),
|
|
82
|
+
schemaHooks.resolveQuery(${camelName}QueryResolver)
|
|
83
|
+
`
|
|
84
|
+
: ''
|
|
85
|
+
}],
|
|
86
|
+
find: [],
|
|
87
|
+
get: [],
|
|
88
|
+
create: [${
|
|
89
|
+
schema
|
|
90
|
+
? `
|
|
91
|
+
schemaHooks.validateData(${camelName}DataValidator),
|
|
92
|
+
schemaHooks.resolveData(${camelName}DataResolver)
|
|
93
|
+
`
|
|
94
|
+
: ''
|
|
95
|
+
}],
|
|
96
|
+
patch: [${
|
|
97
|
+
schema
|
|
98
|
+
? `
|
|
99
|
+
schemaHooks.validateData(${camelName}PatchValidator),
|
|
100
|
+
schemaHooks.resolveData(${camelName}PatchResolver)
|
|
101
|
+
`
|
|
102
|
+
: ''
|
|
103
|
+
}],
|
|
104
|
+
remove: []
|
|
105
|
+
},
|
|
106
|
+
after: {
|
|
107
|
+
all: []
|
|
108
|
+
},
|
|
109
|
+
error: {
|
|
110
|
+
all: []
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Add this service to the service type index
|
|
116
|
+
declare module '${relative}/declarations' {
|
|
117
|
+
interface ServiceTypes {
|
|
118
|
+
'${path}': ${className}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`
|
|
122
|
+
|
|
123
|
+
const toServiceIndex = toFile(({ lib }: ServiceGeneratorContext) => [lib, 'services', `index`])
|
|
124
|
+
|
|
125
|
+
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
126
|
+
generator(ctx)
|
|
127
|
+
.then(
|
|
128
|
+
renderSource(
|
|
129
|
+
template,
|
|
130
|
+
toFile(({ lib, fileName, folder }: ServiceGeneratorContext) => [
|
|
131
|
+
lib,
|
|
132
|
+
'services',
|
|
133
|
+
...folder,
|
|
134
|
+
`${fileName}`
|
|
135
|
+
])
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
.then(
|
|
139
|
+
injectSource<ServiceGeneratorContext>(
|
|
140
|
+
({ camelName, folder, fileName }) =>
|
|
141
|
+
`import { ${camelName} } from './${folder.join('/')}/${fileName}'`,
|
|
142
|
+
prepend(),
|
|
143
|
+
toServiceIndex
|
|
144
|
+
)
|
|
145
|
+
)
|
|
146
|
+
.then(
|
|
147
|
+
injectSource<ServiceGeneratorContext>(
|
|
148
|
+
({ camelName }) => ` app.configure(${camelName})`,
|
|
149
|
+
after('export const services'),
|
|
150
|
+
toServiceIndex
|
|
151
|
+
)
|
|
152
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
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 = ({ relative, lib, path }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html
|
|
7
|
+
import assert from 'assert'
|
|
8
|
+
import { app } from '../${relative}/${lib}/app'
|
|
9
|
+
|
|
10
|
+
describe('${path} service', () => {
|
|
11
|
+
it('registered the service', () => {
|
|
12
|
+
const service = app.service('${path}')
|
|
13
|
+
|
|
14
|
+
assert.ok(service, 'Registered the service')
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
`;
|
|
18
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test, folder, fileName }) => [
|
|
19
|
+
test,
|
|
20
|
+
'services',
|
|
21
|
+
...folder,
|
|
22
|
+
`${fileName}.test`
|
|
23
|
+
])));
|
|
24
|
+
exports.generate = generate;
|
|
25
|
+
//# sourceMappingURL=test.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACR,GAAG,EACH,IAAI,EACoB,EAAE,EAAE,CAAC,QAAQ,CAAC;;0BAEd,QAAQ,IAAI,GAAG;;YAE7B,IAAI;;mCAEmB,IAAI;;;;;CAKtC,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,EAA0B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC9D,IAAI;IACJ,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,OAAO;CACnB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { ServiceGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({
|
|
6
|
+
relative,
|
|
7
|
+
lib,
|
|
8
|
+
path
|
|
9
|
+
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html
|
|
10
|
+
import assert from 'assert'
|
|
11
|
+
import { app } from '../${relative}/${lib}/app'
|
|
12
|
+
|
|
13
|
+
describe('${path} service', () => {
|
|
14
|
+
it('registered the service', () => {
|
|
15
|
+
const service = app.service('${path}')
|
|
16
|
+
|
|
17
|
+
assert.ok(service, 'Registered the service')
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
23
|
+
generator(ctx).then(
|
|
24
|
+
renderSource(
|
|
25
|
+
template,
|
|
26
|
+
toFile<ServiceGeneratorContext>(({ test, folder, fileName }) => [
|
|
27
|
+
test,
|
|
28
|
+
'services',
|
|
29
|
+
...folder,
|
|
30
|
+
`${fileName}.test`
|
|
31
|
+
])
|
|
32
|
+
)
|
|
33
|
+
)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServiceGeneratorContext } from '../index';
|
|
2
|
+
export declare const template: ({ className, upperName, schema, fileName, relative }: ServiceGeneratorContext) => string;
|
|
3
|
+
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -0,0 +1,98 @@
|
|
|
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 template = ({ className, upperName, schema, fileName, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#custom-services
|
|
7
|
+
import type { Id, NullableId, Params, ServiceInterface } from '@feathersjs/feathers'
|
|
8
|
+
|
|
9
|
+
import type { Application } from '${relative}/declarations'
|
|
10
|
+
${schema
|
|
11
|
+
? `import type {
|
|
12
|
+
${upperName},
|
|
13
|
+
${upperName}Data,
|
|
14
|
+
${upperName}Patch,
|
|
15
|
+
${upperName}Query
|
|
16
|
+
} from './${fileName}.schema'
|
|
17
|
+
`
|
|
18
|
+
: `
|
|
19
|
+
export type ${upperName} = any
|
|
20
|
+
export type ${upperName}Data = any
|
|
21
|
+
export type ${upperName}Patch = any
|
|
22
|
+
export type ${upperName}Query = any
|
|
23
|
+
`}
|
|
24
|
+
|
|
25
|
+
export interface ${className}Options {
|
|
26
|
+
app: Application
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ${upperName}Params extends Params<${upperName}Query> {
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// This is a skeleton for a custom service class. Remove or add the methods you need here
|
|
34
|
+
export class ${className} implements ServiceInterface<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
|
|
35
|
+
constructor (public options: ${className}Options) {
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async find (_params?: ${upperName}Params): Promise<${upperName}[]> {
|
|
39
|
+
return []
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
43
|
+
return {
|
|
44
|
+
id: 0,
|
|
45
|
+
text: \`A new message with ID: \${id}!\`
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}>
|
|
50
|
+
async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}[]>
|
|
51
|
+
async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}|${upperName}[]> {
|
|
52
|
+
if (Array.isArray(data)) {
|
|
53
|
+
return Promise.all(data.map(current => this.create(current, params)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
id: 0,
|
|
58
|
+
...data
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// This method has to be added to the 'methods' option to make it available to clients
|
|
63
|
+
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
64
|
+
return {
|
|
65
|
+
id: 0,
|
|
66
|
+
...data
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async patch (id: NullableId, data: ${upperName}Patch, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
71
|
+
return {
|
|
72
|
+
id: 0,
|
|
73
|
+
text: \`Fallback for \${id}\`,
|
|
74
|
+
...data
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
79
|
+
return {
|
|
80
|
+
id: 0,
|
|
81
|
+
text: 'removed'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const getOptions = (app: Application) => {
|
|
87
|
+
return { app }
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
exports.template = template;
|
|
91
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
92
|
+
lib,
|
|
93
|
+
'services',
|
|
94
|
+
...folder,
|
|
95
|
+
`${fileName}.class`
|
|
96
|
+
])));
|
|
97
|
+
exports.generate = generate;
|
|
98
|
+
//# sourceMappingURL=custom.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.tpl.js","sourceRoot":"","sources":["../../../src/service/type/custom.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;oCAGJ,QAAQ;EAE1C,MAAM;IACJ,CAAC,CAAC;IACF,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;CACnB;IACG,CAAC,CAAC;cACQ,SAAS;cACT,SAAS;cACT,SAAS;cACT,SAAS;CAEvB;;mBAEmB,SAAS;;;;mBAIT,SAAS,yBAAyB,SAAS;;;;;eAK/C,SAAS,gCAAgC,SAAS,KAAK,SAAS,SAAS,SAAS,WAAW,SAAS;iCACpF,SAAS;;;0BAGhB,SAAS,oBAAoB,SAAS;;;;iCAI/B,SAAS,oBAAoB,SAAS;;;;;;;wBAO/C,SAAS,kBAAkB,SAAS,oBAAoB,SAAS;wBACjE,SAAS,oBAAoB,SAAS,oBAAoB,SAAS;wBACnE,SAAS,QAAQ,SAAS,oBAAoB,SAAS,oBAAoB,SAAS,IAAI,SAAS;;;;;;;;;;;;wCAYjF,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;uCAOnE,SAAS,oBAAoB,SAAS,oBAAoB,SAAS;;;;;;;;4CAQ9D,SAAS,oBAAoB,SAAS;;;;;;;;;;;CAWjF,CAAA;AA3FY,QAAA,QAAQ,YA2FpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { ServiceGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
export const template = ({
|
|
6
|
+
className,
|
|
7
|
+
upperName,
|
|
8
|
+
schema,
|
|
9
|
+
fileName,
|
|
10
|
+
relative
|
|
11
|
+
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#custom-services
|
|
12
|
+
import type { Id, NullableId, Params, ServiceInterface } from '@feathersjs/feathers'
|
|
13
|
+
|
|
14
|
+
import type { Application } from '${relative}/declarations'
|
|
15
|
+
${
|
|
16
|
+
schema
|
|
17
|
+
? `import type {
|
|
18
|
+
${upperName},
|
|
19
|
+
${upperName}Data,
|
|
20
|
+
${upperName}Patch,
|
|
21
|
+
${upperName}Query
|
|
22
|
+
} from './${fileName}.schema'
|
|
23
|
+
`
|
|
24
|
+
: `
|
|
25
|
+
export type ${upperName} = any
|
|
26
|
+
export type ${upperName}Data = any
|
|
27
|
+
export type ${upperName}Patch = any
|
|
28
|
+
export type ${upperName}Query = any
|
|
29
|
+
`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ${className}Options {
|
|
33
|
+
app: Application
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ${upperName}Params extends Params<${upperName}Query> {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// This is a skeleton for a custom service class. Remove or add the methods you need here
|
|
41
|
+
export class ${className} implements ServiceInterface<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
|
|
42
|
+
constructor (public options: ${className}Options) {
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async find (_params?: ${upperName}Params): Promise<${upperName}[]> {
|
|
46
|
+
return []
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
50
|
+
return {
|
|
51
|
+
id: 0,
|
|
52
|
+
text: \`A new message with ID: \${id}!\`
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}>
|
|
57
|
+
async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}[]>
|
|
58
|
+
async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}|${upperName}[]> {
|
|
59
|
+
if (Array.isArray(data)) {
|
|
60
|
+
return Promise.all(data.map(current => this.create(current, params)));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
id: 0,
|
|
65
|
+
...data
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// This method has to be added to the 'methods' option to make it available to clients
|
|
70
|
+
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
71
|
+
return {
|
|
72
|
+
id: 0,
|
|
73
|
+
...data
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async patch (id: NullableId, data: ${upperName}Patch, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
78
|
+
return {
|
|
79
|
+
id: 0,
|
|
80
|
+
text: \`Fallback for \${id}\`,
|
|
81
|
+
...data
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
86
|
+
return {
|
|
87
|
+
id: 0,
|
|
88
|
+
text: 'removed'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const getOptions = (app: Application) => {
|
|
94
|
+
return { app }
|
|
95
|
+
}
|
|
96
|
+
`
|
|
97
|
+
|
|
98
|
+
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
99
|
+
generator(ctx).then(
|
|
100
|
+
renderSource(
|
|
101
|
+
template,
|
|
102
|
+
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
103
|
+
lib,
|
|
104
|
+
'services',
|
|
105
|
+
...folder,
|
|
106
|
+
`${fileName}.class`
|
|
107
|
+
])
|
|
108
|
+
)
|
|
109
|
+
)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServiceGeneratorContext } from '../index';
|
|
2
|
+
export declare const template: ({ className, upperName, feathers, schema, fileName, relative }: ServiceGeneratorContext) => string;
|
|
3
|
+
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 migrationTemplate = ({ kebabPath }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/knexfile.html
|
|
7
|
+
import type { Knex } from 'knex'
|
|
8
|
+
|
|
9
|
+
export async function up(knex: Knex): Promise<void> {
|
|
10
|
+
await knex.schema.createTable('${kebabPath}', table => {
|
|
11
|
+
table.increments('id')
|
|
12
|
+
table.string('text')
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function down(knex: Knex): Promise<void> {
|
|
17
|
+
await knex.schema.dropTable('${kebabPath}')
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const template = ({ className, upperName, feathers, schema, fileName, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services
|
|
21
|
+
import type { Params } from '@feathersjs/feathers'
|
|
22
|
+
import { KnexService } from '@feathersjs/knex'
|
|
23
|
+
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
|
|
24
|
+
|
|
25
|
+
import type { Application } from '${relative}/declarations'
|
|
26
|
+
${schema
|
|
27
|
+
? `import type {
|
|
28
|
+
${upperName},
|
|
29
|
+
${upperName}Data,
|
|
30
|
+
${upperName}Patch,
|
|
31
|
+
${upperName}Query
|
|
32
|
+
} from './${fileName}.schema'
|
|
33
|
+
`
|
|
34
|
+
: `
|
|
35
|
+
export type ${upperName} = any
|
|
36
|
+
export type ${upperName}Data = any
|
|
37
|
+
export type ${upperName}Patch = any
|
|
38
|
+
export type ${upperName}Query = any
|
|
39
|
+
`}
|
|
40
|
+
|
|
41
|
+
export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
|
|
45
|
+
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
46
|
+
extends KnexService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const getOptions = (app: Application): KnexAdapterOptions => {
|
|
50
|
+
return {
|
|
51
|
+
paginate: app.get('paginate'),
|
|
52
|
+
Model: app.get('${feathers.database}Client'),
|
|
53
|
+
name: '${fileName}'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
exports.template = template;
|
|
58
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
59
|
+
.then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
60
|
+
lib,
|
|
61
|
+
'services',
|
|
62
|
+
...folder,
|
|
63
|
+
`${fileName}.class`
|
|
64
|
+
])))
|
|
65
|
+
.then((0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)('migrations', ({ kebabName }) => {
|
|
66
|
+
// Probably not great but it works to align with the Knex migration file format
|
|
67
|
+
const migrationDate = new Date().toISOString().replace(/\D/g, '').substring(0, 14);
|
|
68
|
+
return `${migrationDate}_${kebabName}`;
|
|
69
|
+
})));
|
|
70
|
+
exports.generate = generate;
|
|
71
|
+
//# sourceMappingURL=knex.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/service/type/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,CAAC,EACzB,SAAS,EACe,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;mCAIL,SAAS;;;;;;;iCAOX,SAAS;;CAEzC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;oCAKJ,QAAQ;EAE1C,MAAM;IACJ,CAAC,CAAC;IACF,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;CACnB;IACG,CAAC,CAAC;cACQ,SAAS;cACT,SAAS;cACT,SAAS;cACT,SAAS;CAEvB;;mBAEmB,SAAS,oCAAoC,SAAS;;;;eAI1D,SAAS,mCAAmC,SAAS;wBAC5C,SAAS,KAAK,SAAS,wBAAwB,SAAS;;;;;;sBAM1D,QAAQ,CAAC,QAAQ;aAC1B,QAAQ;;;CAGpB,CAAA;AA7CY,QAAA,QAAQ,YA6CpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CACH,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAA0B,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAC9D,+EAA+E;IAC/E,MAAM,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAElF,OAAO,GAAG,aAAa,IAAI,SAAS,EAAE,CAAA;AACxC,CAAC,CAAC,CACH,CACF,CAAA;AAvBQ,QAAA,QAAQ,YAuBhB"}
|