@feathersjs/cli 5.0.0-pre.32 → 5.0.0-pre.34
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 +26 -0
- package/LICENSE +1 -2
- package/README.md +3 -7
- package/lib/app/index.d.ts +2 -2
- package/lib/app/index.js +1 -1
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +1 -0
- package/lib/app/templates/app.test.tpl.js +2 -1
- package/lib/app/templates/app.test.tpl.js.map +1 -1
- package/lib/app/templates/app.test.tpl.ts +4 -1
- package/lib/app/templates/app.tpl.js +12 -10
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +12 -10
- package/lib/app/templates/channels.tpl.js +2 -1
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +2 -1
- package/lib/app/templates/client.tpl.js +2 -1
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +2 -1
- package/lib/app/templates/{config.tpl.d.ts → configuration.tpl.d.ts} +0 -0
- package/lib/app/templates/{schemas.tpl.js → configuration.tpl.js} +25 -29
- package/lib/app/templates/configuration.tpl.js.map +1 -0
- package/lib/app/templates/{schemas.tpl.ts → configuration.tpl.ts} +25 -32
- package/lib/app/templates/declarations.tpl.js +3 -2
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +3 -2
- package/lib/app/templates/logger.tpl.d.ts +1 -0
- package/lib/app/templates/logger.tpl.js +13 -7
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +22 -10
- package/lib/app/templates/package.json.tpl.js +5 -2
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +5 -2
- package/lib/app/templates/services.tpl.js +2 -1
- package/lib/app/templates/services.tpl.js.map +1 -1
- package/lib/app/templates/services.tpl.ts +3 -1
- package/lib/app/templates/{schemas.tpl.d.ts → validators.tpl.d.ts} +0 -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 +1 -1
- package/lib/authentication/templates/authentication.tpl.js +2 -1
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +2 -1
- package/lib/authentication/templates/client.test.tpl.js +2 -1
- package/lib/authentication/templates/client.test.tpl.js.map +1 -1
- package/lib/authentication/templates/client.test.tpl.ts +2 -1
- package/lib/authentication/templates/knex.tpl.js +2 -2
- package/lib/authentication/templates/knex.tpl.js.map +1 -1
- package/lib/authentication/templates/knex.tpl.ts +2 -2
- package/lib/authentication/templates/schema.json.tpl.js +30 -20
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.json.tpl.ts +37 -21
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +1 -1
- package/lib/authentication/templates/schema.typebox.tpl.js +30 -22
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +37 -23
- package/lib/commons.d.ts +11 -4
- package/lib/commons.js +9 -1
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +8 -0
- package/lib/connection/index.d.ts +1 -1
- package/lib/connection/index.js +2 -2
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +2 -2
- package/lib/connection/templates/knex.tpl.js +4 -2
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -2
- package/lib/connection/templates/mongodb.tpl.js +3 -2
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +4 -2
- package/lib/hook/templates/hook.tpl.js +4 -2
- package/lib/hook/templates/hook.tpl.js.map +1 -1
- package/lib/hook/templates/hook.tpl.ts +4 -2
- package/lib/service/index.d.ts +1 -1
- package/lib/service/templates/schema.json.tpl.js +23 -15
- package/lib/service/templates/schema.json.tpl.js.map +1 -1
- package/lib/service/templates/schema.json.tpl.ts +28 -17
- package/lib/service/templates/schema.typebox.tpl.js +21 -15
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/service/templates/schema.typebox.tpl.ts +26 -17
- package/lib/service/templates/service.tpl.js +33 -19
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +38 -20
- package/lib/service/templates/test.tpl.js +2 -1
- package/lib/service/templates/test.tpl.js.map +1 -1
- package/lib/service/templates/test.tpl.ts +6 -1
- package/lib/service/type/custom.tpl.js +8 -4
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +14 -4
- package/lib/service/type/knex.tpl.js +7 -3
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +7 -3
- package/lib/service/type/mongodb.tpl.js +5 -2
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +5 -2
- package/package.json +27 -25
- package/lib/app/templates/config.tpl.js +0 -30
- package/lib/app/templates/config.tpl.js.map +0 -1
- package/lib/app/templates/config.tpl.ts +0 -31
- package/lib/app/templates/schemas.tpl.js.map +0 -1
- package/lib/authentication/templates/client.tpl.d.ts +0 -2
- package/lib/authentication/templates/client.tpl.js +0 -14
- package/lib/authentication/templates/client.tpl.js.map +0 -1
- package/lib/authentication/templates/client.tpl.ts +0 -19
|
@@ -4,13 +4,15 @@ exports.generate = exports.template = void 0;
|
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
6
|
const index_1 = require("../index");
|
|
7
|
-
const template = ({ camelName, upperName, authStrategies, type, relative }) => /* ts */
|
|
7
|
+
const template = ({ cwd, lib, camelName, upperName, authStrategies, type, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
|
|
8
|
+
import { resolve } from '@feathersjs/schema'
|
|
8
9
|
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
9
10
|
import type { Static } from '@feathersjs/typebox'
|
|
10
11
|
${(0, index_1.localTemplate)(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
|
|
11
12
|
|
|
12
13
|
import type { HookContext } from '${relative}/declarations'
|
|
13
|
-
import { dataValidator, queryValidator } from '${relative}
|
|
14
|
+
import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
|
|
15
|
+
}validators'
|
|
14
16
|
|
|
15
17
|
// Main data model schema
|
|
16
18
|
export const ${camelName}Schema = Type.Object({
|
|
@@ -23,18 +25,14 @@ export const ${camelName}Schema = Type.Object({
|
|
|
23
25
|
.join(',\n')}
|
|
24
26
|
},{ $id: '${upperName}', additionalProperties: false })
|
|
25
27
|
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
26
|
-
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
27
|
-
properties: {}
|
|
28
|
-
})
|
|
28
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
|
|
29
29
|
|
|
30
30
|
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
password: async () => undefined
|
|
34
|
-
}
|
|
31
|
+
${(0, index_1.localTemplate)(authStrategies, `// The password should never be visible externally
|
|
32
|
+
password: async () => undefined`)}
|
|
35
33
|
})
|
|
36
34
|
|
|
37
|
-
// Schema for
|
|
35
|
+
// Schema for creating new users
|
|
38
36
|
export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
|
|
39
37
|
${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
|
|
40
38
|
],
|
|
@@ -43,27 +41,37 @@ export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
|
|
|
43
41
|
export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
|
|
44
42
|
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
45
43
|
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Schema for updating existing users
|
|
48
|
+
export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
|
|
49
|
+
$id: '${upperName}Patch'
|
|
50
|
+
})
|
|
51
|
+
export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
|
|
52
|
+
export const ${camelName}PatchValidator = getDataValidator(${camelName}PatchSchema, dataValidator)
|
|
53
|
+
export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({
|
|
54
|
+
${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
|
|
49
55
|
})
|
|
50
56
|
|
|
51
57
|
// Schema for allowed query properties
|
|
52
58
|
export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${type === 'mongodb' ? '_id' : 'id'}', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
|
|
53
59
|
])
|
|
54
|
-
export const ${camelName}QuerySchema =
|
|
60
|
+
export const ${camelName}QuerySchema = Type.Intersect([
|
|
61
|
+
querySyntax(${camelName}QueryProperties),
|
|
62
|
+
// Add additional query properties here
|
|
63
|
+
Type.Object({}, { additionalProperties: false })
|
|
64
|
+
], { additionalProperties: false })
|
|
55
65
|
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
56
66
|
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
57
67
|
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return value
|
|
68
|
+
// If there is a user (e.g. with authentication), they are only allowed to see their own data
|
|
69
|
+
${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
|
|
70
|
+
if (context.params.user) {
|
|
71
|
+
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
|
|
66
72
|
}
|
|
73
|
+
|
|
74
|
+
return value
|
|
67
75
|
}
|
|
68
76
|
})
|
|
69
77
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AACxD,oCAAwE;AAEjE,MAAM,QAAQ,GAAG,CAAC,EACvB,GAAG,EACH,GAAG,EACH,SAAS,EACT,SAAS,EACT,cAAc,EACd,IAAI,EACJ,QAAQ,EACuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;EAI7C,IAAA,qBAAa,EAAC,cAAc,EAAE,iEAAiE,CAAC;;oCAE9D,QAAQ;iDACK,QAAQ,IACvD,IAAA,oBAAU,EAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,6CAA6C;AACjG;;;eAGe,SAAS;IACpB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,mBAAmB;IAC/D,cAAc;KACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;yCAC+B;IACjC,CAA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IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;;;;CAMnE,CAAA;AAtFY,QAAA,QAAQ,YAsFpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,EACpC,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC;IACpE,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CACF,CAAA;AAfU,QAAA,QAAQ,YAelB"}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { generator, toFile, when } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
2
|
+
import { fileExists, renderSource } from '../../commons'
|
|
3
3
|
import { AuthenticationGeneratorContext, localTemplate } from '../index'
|
|
4
4
|
|
|
5
5
|
export const template = ({
|
|
6
|
+
cwd,
|
|
7
|
+
lib,
|
|
6
8
|
camelName,
|
|
7
9
|
upperName,
|
|
8
10
|
authStrategies,
|
|
9
11
|
type,
|
|
10
12
|
relative
|
|
11
|
-
}: AuthenticationGeneratorContext) => /* ts */
|
|
13
|
+
}: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
|
|
14
|
+
import { resolve } from '@feathersjs/schema'
|
|
12
15
|
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
13
16
|
import type { Static } from '@feathersjs/typebox'
|
|
14
17
|
${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
|
|
15
18
|
|
|
16
19
|
import type { HookContext } from '${relative}/declarations'
|
|
17
|
-
import { dataValidator, queryValidator } from '${relative}
|
|
20
|
+
import { dataValidator, queryValidator } from '${relative}/${
|
|
21
|
+
fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
|
|
22
|
+
}validators'
|
|
18
23
|
|
|
19
24
|
// Main data model schema
|
|
20
25
|
export const ${camelName}Schema = Type.Object({
|
|
@@ -29,18 +34,17 @@ export const ${camelName}Schema = Type.Object({
|
|
|
29
34
|
.join(',\n')}
|
|
30
35
|
},{ $id: '${upperName}', additionalProperties: false })
|
|
31
36
|
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
32
|
-
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
33
|
-
properties: {}
|
|
34
|
-
})
|
|
37
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
|
|
35
38
|
|
|
36
39
|
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
password
|
|
40
|
-
|
|
40
|
+
${localTemplate(
|
|
41
|
+
authStrategies,
|
|
42
|
+
`// The password should never be visible externally
|
|
43
|
+
password: async () => undefined`
|
|
44
|
+
)}
|
|
41
45
|
})
|
|
42
46
|
|
|
43
|
-
// Schema for
|
|
47
|
+
// Schema for creating new users
|
|
44
48
|
export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
|
|
45
49
|
${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
|
|
46
50
|
],
|
|
@@ -49,9 +53,17 @@ export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
|
|
|
49
53
|
export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
|
|
50
54
|
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
51
55
|
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// Schema for updating existing users
|
|
60
|
+
export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
|
|
61
|
+
$id: '${upperName}Patch'
|
|
62
|
+
})
|
|
63
|
+
export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
|
|
64
|
+
export const ${camelName}PatchValidator = getDataValidator(${camelName}PatchSchema, dataValidator)
|
|
65
|
+
export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({
|
|
66
|
+
${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
|
|
55
67
|
})
|
|
56
68
|
|
|
57
69
|
// Schema for allowed query properties
|
|
@@ -59,19 +71,21 @@ export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${
|
|
|
59
71
|
type === 'mongodb' ? '_id' : 'id'
|
|
60
72
|
}', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
|
|
61
73
|
])
|
|
62
|
-
export const ${camelName}QuerySchema =
|
|
74
|
+
export const ${camelName}QuerySchema = Type.Intersect([
|
|
75
|
+
querySyntax(${camelName}QueryProperties),
|
|
76
|
+
// Add additional query properties here
|
|
77
|
+
Type.Object({}, { additionalProperties: false })
|
|
78
|
+
], { additionalProperties: false })
|
|
63
79
|
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
64
80
|
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
65
81
|
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return value
|
|
82
|
+
// If there is a user (e.g. with authentication), they are only allowed to see their own data
|
|
83
|
+
${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
|
|
84
|
+
if (context.params.user) {
|
|
85
|
+
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
|
|
74
86
|
}
|
|
87
|
+
|
|
88
|
+
return value
|
|
75
89
|
}
|
|
76
90
|
})
|
|
77
91
|
`
|
package/lib/commons.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { Callable, PinionContext, Location } from '@feathershq/pinion';
|
|
|
3
3
|
import * as ts from 'typescript';
|
|
4
4
|
import { Options as PrettierOptions } from 'prettier';
|
|
5
5
|
export declare const version: any;
|
|
6
|
-
export
|
|
6
|
+
export type DependencyVersions = {
|
|
7
7
|
[key: string]: string;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* The database types supported by this generator
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type DatabaseType = 'mongodb' | 'mysql' | 'postgresql' | 'sqlite' | 'mssql';
|
|
13
13
|
/**
|
|
14
14
|
* Returns the name of the Feathers database adapter for a supported database type
|
|
15
15
|
*
|
|
@@ -17,7 +17,7 @@ export declare type DatabaseType = 'mongodb' | 'mysql' | 'postgresql' | 'sqlite'
|
|
|
17
17
|
* @returns The name of the adapter
|
|
18
18
|
*/
|
|
19
19
|
export declare const getDatabaseAdapter: (database: DatabaseType) => "mongodb" | "knex";
|
|
20
|
-
export
|
|
20
|
+
export type FeathersAppInfo = {
|
|
21
21
|
/**
|
|
22
22
|
* The application language
|
|
23
23
|
*/
|
|
@@ -88,7 +88,7 @@ export declare const addVersions: (dependencies: string[], versions: DependencyV
|
|
|
88
88
|
*
|
|
89
89
|
* @returns The updated context
|
|
90
90
|
*/
|
|
91
|
-
export declare const initializeBaseContext: () => <C extends FeathersBaseContext>(ctx: C) => Promise<C & {
|
|
91
|
+
export declare const initializeBaseContext: () => <C extends FeathersBaseContext>(ctx: C) => Promise<Awaited<C> & {
|
|
92
92
|
lib: string;
|
|
93
93
|
test: string;
|
|
94
94
|
language: "ts" | "js";
|
|
@@ -141,3 +141,10 @@ export declare const renderSource: <C extends PinionContext & {
|
|
|
141
141
|
export declare const injectSource: <C extends PinionContext & {
|
|
142
142
|
language: 'js' | 'ts';
|
|
143
143
|
}>(template: Callable<string, C>, location: Location<C>, target: Callable<string, C>, transpile?: boolean) => (ctx: C) => Promise<C>;
|
|
144
|
+
/**
|
|
145
|
+
* Synchronously checks if a file exits
|
|
146
|
+
* @param context The base context
|
|
147
|
+
* @param filenames The filenames to check
|
|
148
|
+
* @returns Wether the file exists or not
|
|
149
|
+
*/
|
|
150
|
+
export declare const fileExists: (...filenames: string[]) => boolean;
|
package/lib/commons.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.injectSource = exports.renderSource = exports.prettify = exports.PRETTIERRC = exports.getJavaScript = exports.checkPreconditions = exports.initializeBaseContext = exports.addVersions = exports.getDatabaseAdapter = exports.version = void 0;
|
|
29
|
+
exports.fileExists = exports.injectSource = exports.renderSource = exports.prettify = exports.PRETTIERRC = exports.getJavaScript = exports.checkPreconditions = exports.initializeBaseContext = exports.addVersions = exports.getDatabaseAdapter = exports.version = void 0;
|
|
30
30
|
const fs_1 = __importDefault(require("fs"));
|
|
31
31
|
const path_1 = require("path");
|
|
32
32
|
const promises_1 = require("fs/promises");
|
|
@@ -187,4 +187,12 @@ const injectSource = (template, location, target, transpile = true) => async (ct
|
|
|
187
187
|
return injector(ctx).then((0, exports.prettify)(target));
|
|
188
188
|
};
|
|
189
189
|
exports.injectSource = injectSource;
|
|
190
|
+
/**
|
|
191
|
+
* Synchronously checks if a file exits
|
|
192
|
+
* @param context The base context
|
|
193
|
+
* @param filenames The filenames to check
|
|
194
|
+
* @returns Wether the file exists or not
|
|
195
|
+
*/
|
|
196
|
+
const fileExists = (...filenames) => fs_1.default.existsSync((0, path_1.join)(...filenames));
|
|
197
|
+
exports.fileExists = fileExists;
|
|
190
198
|
//# sourceMappingURL=commons.js.map
|
package/lib/commons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commons.js","sourceRoot":"","sources":["../src/commons.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,+BAA2B;AAE3B,0CAAiD;AACjD,+CAS2B;AAC3B,+CAAgC;AAChC,wDAA+D;AAC/D,gDAAuB;AAER,eAAO,GAAK,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAA;AASxG;;;;;GAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,QAAsB,EAAE,EAAE,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAA9F,QAAA,kBAAkB,sBAA4E;AA8D3G;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CAAC,YAAsB,EAAE,QAA4B,EAAE,EAAE,CAClF,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;AADpE,QAAA,WAAW,eACyD;AAEjF;;;;;GAKG;AACI,MAAM,qBAAqB,GAChC,GAAG,EAAE,CACL,CAAgC,GAAM,EAAE,EAAE,CACxC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,IAAA,iBAAQ,EAAC,IAAA,iBAAQ,EAAC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EA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AAG,MAAM,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/C,MAAM,QAAQ,GAAG,IAAA,eAAM,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEnD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,CAAC,CAAA;AAC7C,CAAC,CAAA;AAfU,QAAA,YAAY,gBAetB;AAEH;;;;;GAKG;AACI,MAAM,UAAU,GAAG,CAAC,GAAG,SAAmB,EAAE,EAAE,CAAC,YAAE,CAAC,UAAU,CAAC,IAAA,WAAI,EAAC,GAAG,SAAS,CAAC,CAAC,CAAA;AAA1E,QAAA,UAAU,cAAgE"}
|
package/lib/commons.ts
CHANGED
|
@@ -274,3 +274,11 @@ export const injectSource =
|
|
|
274
274
|
|
|
275
275
|
return injector(ctx).then(prettify(target))
|
|
276
276
|
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Synchronously checks if a file exits
|
|
280
|
+
* @param context The base context
|
|
281
|
+
* @param filenames The filenames to check
|
|
282
|
+
* @returns Wether the file exists or not
|
|
283
|
+
*/
|
|
284
|
+
export const fileExists = (...filenames: string[]) => fs.existsSync(join(...filenames))
|
|
@@ -5,7 +5,7 @@ export interface ConnectionGeneratorContext extends FeathersBaseContext {
|
|
|
5
5
|
connectionString: string;
|
|
6
6
|
dependencies: string[];
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export type ConnectionGeneratorArguments = FeathersBaseContext & Partial<Pick<ConnectionGeneratorContext, 'database' | 'connectionString' | 'name'>>;
|
|
9
9
|
export declare const defaultConnectionString: (type: DatabaseType, name: string) => string;
|
|
10
10
|
export declare const prompts: ({ database, connectionString, pkg, name }: ConnectionGeneratorArguments) => ({
|
|
11
11
|
name: string;
|
package/lib/connection/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
9
9
|
const commons_1 = require("../commons");
|
|
10
10
|
const defaultConnectionString = (type, name) => {
|
|
11
11
|
const connectionStrings = {
|
|
12
|
-
mongodb: `mongodb://
|
|
12
|
+
mongodb: `mongodb://127.0.0.1:27017/${name}`,
|
|
13
13
|
mysql: `mysql://root:@localhost:3306/${name}`,
|
|
14
14
|
postgresql: `postgres://postgres:@localhost:5432/${name}`,
|
|
15
15
|
sqlite: `${name}.sqlite`,
|
|
@@ -47,7 +47,7 @@ exports.DATABASE_CLIENTS = {
|
|
|
47
47
|
sqlite: 'sqlite3',
|
|
48
48
|
postgresql: 'pg',
|
|
49
49
|
mysql: 'mysql',
|
|
50
|
-
mssql: '
|
|
50
|
+
mssql: 'mssql'
|
|
51
51
|
};
|
|
52
52
|
const getDatabaseClient = (database) => exports.DATABASE_CLIENTS[database];
|
|
53
53
|
exports.getDatabaseClient = getDatabaseClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAgG;AAChG,kDAAyB;AACzB,wCAOmB;AAYZ,MAAM,uBAAuB,GAAG,CAAC,IAAkB,EAAE,IAAY,EAAE,EAAE;IAC1E,MAAM,iBAAiB,GAAG;QACxB,OAAO,EAAE,6BAA6B,IAAI,EAAE;QAC5C,KAAK,EAAE,gCAAgC,IAAI,EAAE;QAC7C,UAAU,EAAE,uCAAuC,IAAI,EAAE;QACzD,MAAM,EAAE,GAAG,IAAI,SAAS;QACxB,KAAK,EAAE,wCAAwC,IAAI,EAAE;KACtD,CAAA;IAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC,CAAA;AAVY,QAAA,uBAAuB,2BAUnC;AAEM,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAgC,EAAE,EAAE,CAAC;IAClG;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM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,GAAG,IAAA,yBAAiB,EAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEhD,YAAY,CAAC,IAAI,CAAC,eAAe,OAAO,EAAE,CAAC,CAAA;IAE3C,IAAI,OAAO,KAAK,MAAM,EAAE;QACtB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;KAC1B;IAED,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAE3B,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,OAAO;YACL,GAAG,GAAG;YACN,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,YAAY,CAAC;SACrD,CAAA;KACF;IAED,OAAO,IAAA,gBAAO,EACZ,IAAA,qBAAW,EAAC,YAAY,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACjD,KAAK,EACL,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACtB,CAAC,GAAG,CAAC,CAAA;AACR,CAAC,CAAC,CAAA;AAtDO,QAAA,QAAQ,YAsDf"}
|
package/lib/connection/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type ConnectionGeneratorArguments = FeathersBaseContext &
|
|
|
21
21
|
|
|
22
22
|
export const defaultConnectionString = (type: DatabaseType, name: string) => {
|
|
23
23
|
const connectionStrings = {
|
|
24
|
-
mongodb: `mongodb://
|
|
24
|
+
mongodb: `mongodb://127.0.0.1:27017/${name}`,
|
|
25
25
|
mysql: `mysql://root:@localhost:3306/${name}`,
|
|
26
26
|
postgresql: `postgres://postgres:@localhost:5432/${name}`,
|
|
27
27
|
sqlite: `${name}.sqlite`,
|
|
@@ -61,7 +61,7 @@ export const DATABASE_CLIENTS = {
|
|
|
61
61
|
sqlite: 'sqlite3',
|
|
62
62
|
postgresql: 'pg',
|
|
63
63
|
mysql: 'mysql',
|
|
64
|
-
mssql: '
|
|
64
|
+
mssql: 'mssql'
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export const getDatabaseClient = (database: DatabaseType) => DATABASE_CLIENTS[database]
|
|
@@ -3,7 +3,8 @@ 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 = ({ database }) => /* ts */
|
|
6
|
+
const template = ({ database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
7
|
+
import knex from 'knex'
|
|
7
8
|
import type { Knex } from 'knex'
|
|
8
9
|
import type { Application } from './declarations'
|
|
9
10
|
|
|
@@ -20,7 +21,8 @@ export const ${database} = (app: Application) => {
|
|
|
20
21
|
app.set('${database}Client', db)
|
|
21
22
|
}
|
|
22
23
|
`;
|
|
23
|
-
const knexfile = ({ lib, language, database }) => /* ts */
|
|
24
|
+
const knexfile = ({ lib, language, database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
25
|
+
import { app } from './${lib}/app'
|
|
24
26
|
|
|
25
27
|
// Load our database connection info from the app configuration
|
|
26
28
|
const config = app.get('${database}')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAEzE,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAEzE,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACmB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;MAOrC,QAAQ;;;;eAIC,QAAQ;4BACK,QAAQ;;;aAGvB,QAAQ;;CAEpB,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,EAChB,GAAG,EACH,QAAQ,EACR,QAAQ,EACmB,EAAE,EAAE,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;AAtB3E,QAAA,QAAQ,YAsBmE"}
|
|
@@ -2,7 +2,10 @@ import { generator, toFile, before, mergeJSON } from '@feathershq/pinion'
|
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
3
|
import { injectSource, renderSource } from '../../commons'
|
|
4
4
|
|
|
5
|
-
const template = ({
|
|
5
|
+
const template = ({
|
|
6
|
+
database
|
|
7
|
+
}: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
8
|
+
import knex from 'knex'
|
|
6
9
|
import type { Knex } from 'knex'
|
|
7
10
|
import type { Application } from './declarations'
|
|
8
11
|
|
|
@@ -24,7 +27,8 @@ const knexfile = ({
|
|
|
24
27
|
lib,
|
|
25
28
|
language,
|
|
26
29
|
database
|
|
27
|
-
}: ConnectionGeneratorContext) => /* ts */
|
|
30
|
+
}: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
31
|
+
import { app } from './${lib}/app'
|
|
28
32
|
|
|
29
33
|
// Load our database connection info from the app configuration
|
|
30
34
|
const config = app.get('${database}')
|
|
@@ -3,7 +3,8 @@ 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 = ({}) => /* ts */
|
|
6
|
+
const template = ({}) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
7
|
+
import { MongoClient } from 'mongodb'
|
|
7
8
|
import type { Db } from 'mongodb'
|
|
8
9
|
import type { Application } from './declarations'
|
|
9
10
|
|
|
@@ -15,7 +16,7 @@ declare module './declarations' {
|
|
|
15
16
|
|
|
16
17
|
export const mongodb = (app: Application) => {
|
|
17
18
|
const connection = app.get('mongodb') as string
|
|
18
|
-
const database = connection.substring(
|
|
19
|
+
const database = new URL(connection).pathname.substring(1)
|
|
19
20
|
const mongoClient = MongoClient.connect(connection)
|
|
20
21
|
.then(client => client.db(database))
|
|
21
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAE9D,2CAA0D;AAE1D,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAE9D,2CAA0D;AAE1D,MAAM,QAAQ,GACZ,CAAC,EAA8B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;CAmB9C,CAAA;AAED,MAAM,cAAc,GAAG,qCAAqC,CAAA;AAC5D,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAClD,MAAM,SAAS,GAAG,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAExE,MAAM,QAAQ,GAAG,CAAC,GAA+B,EAAE,EAAE,CAC1D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,CAChE,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"}
|
|
@@ -2,7 +2,9 @@ import { generator, toFile, before } from '@feathershq/pinion'
|
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
3
|
import { injectSource, renderSource } from '../../commons'
|
|
4
4
|
|
|
5
|
-
const template =
|
|
5
|
+
const template =
|
|
6
|
+
({}: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
7
|
+
import { MongoClient } from 'mongodb'
|
|
6
8
|
import type { Db } from 'mongodb'
|
|
7
9
|
import type { Application } from './declarations'
|
|
8
10
|
|
|
@@ -14,7 +16,7 @@ declare module './declarations' {
|
|
|
14
16
|
|
|
15
17
|
export const mongodb = (app: Application) => {
|
|
16
18
|
const connection = app.get('mongodb') as string
|
|
17
|
-
const database = connection.substring(
|
|
19
|
+
const database = new URL(connection).pathname.substring(1)
|
|
18
20
|
const mongoClient = MongoClient.connect(connection)
|
|
19
21
|
.then(client => client.db(database))
|
|
20
22
|
|
|
@@ -3,14 +3,16 @@ 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 aroundTemplate = ({ camelName, name }) => /* ts */
|
|
6
|
+
const aroundTemplate = ({ camelName, name }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
|
|
7
|
+
import type { HookContext, NextFunction } from '../declarations'
|
|
7
8
|
|
|
8
9
|
export const ${camelName} = async (context: HookContext, next: NextFunction) => {
|
|
9
10
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
10
11
|
await next()
|
|
11
12
|
}
|
|
12
13
|
`;
|
|
13
|
-
const regularTemplate = ({ camelName, name }) => /* ts */
|
|
14
|
+
const regularTemplate = ({ camelName, name }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
|
|
15
|
+
import type { HookContext } from '../declarations'
|
|
14
16
|
|
|
15
17
|
export const ${camelName} = async (context: HookContext) => {
|
|
16
18
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.tpl.js","sourceRoot":"","sources":["../../../src/hook/templates/hook.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"hook.tpl.js","sourceRoot":"","sources":["../../../src/hook/templates/hook.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;eAGtB,SAAS;+BACO,IAAI;;;CAGlC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;eAGtB,SAAS;+BACO,IAAI;EACjC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAAyB,EAAE,EAAE,CACpD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAC7E,IAAA,eAAM,EAAuB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAChF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -5,7 +5,8 @@ import { renderSource } from '../../commons'
|
|
|
5
5
|
const aroundTemplate = ({
|
|
6
6
|
camelName,
|
|
7
7
|
name
|
|
8
|
-
}: HookGeneratorContext) => /* ts */
|
|
8
|
+
}: HookGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
|
|
9
|
+
import type { HookContext, NextFunction } from '../declarations'
|
|
9
10
|
|
|
10
11
|
export const ${camelName} = async (context: HookContext, next: NextFunction) => {
|
|
11
12
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
@@ -16,7 +17,8 @@ export const ${camelName} = async (context: HookContext, next: NextFunction) =>
|
|
|
16
17
|
const regularTemplate = ({
|
|
17
18
|
camelName,
|
|
18
19
|
name
|
|
19
|
-
}: HookGeneratorContext) => /* ts */
|
|
20
|
+
}: HookGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
|
|
21
|
+
import type { HookContext } from '../declarations'
|
|
20
22
|
|
|
21
23
|
export const ${camelName} = async (context: HookContext) => {
|
|
22
24
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
package/lib/service/index.d.ts
CHANGED
|
@@ -60,5 +60,5 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
60
60
|
/**
|
|
61
61
|
* Parameters the generator is called with
|
|
62
62
|
*/
|
|
63
|
-
export
|
|
63
|
+
export type ServiceGeneratorArguments = FeathersBaseContext & Partial<Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService' | 'schema'>>;
|
|
64
64
|
export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<ServiceGeneratorContext>;
|
|
@@ -3,11 +3,13 @@ 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, type }) => /* ts */
|
|
6
|
+
const template = ({ camelName, upperName, relative, type, cwd, lib }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
|
|
7
|
+
import { resolve, getValidator, querySyntax } from '@feathersjs/schema'
|
|
7
8
|
import type { FromSchema } from '@feathersjs/schema'
|
|
8
9
|
|
|
9
10
|
import type { HookContext } from '${relative}/declarations'
|
|
10
|
-
import { dataValidator, queryValidator } from '${relative}
|
|
11
|
+
import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
|
|
12
|
+
}validators'
|
|
11
13
|
|
|
12
14
|
// Main data model schema
|
|
13
15
|
export const ${camelName}Schema = {
|
|
@@ -25,12 +27,8 @@ export const ${camelName}Schema = {
|
|
|
25
27
|
}
|
|
26
28
|
} as const
|
|
27
29
|
export type ${upperName} = FromSchema<typeof ${camelName}Schema>
|
|
28
|
-
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
29
|
-
|
|
30
|
-
})
|
|
31
|
-
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
32
|
-
properties: {}
|
|
33
|
-
})
|
|
30
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
|
|
31
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({})
|
|
34
32
|
|
|
35
33
|
// Schema for creating new data
|
|
36
34
|
export const ${camelName}DataSchema = {
|
|
@@ -45,10 +43,22 @@ export const ${camelName}DataSchema = {
|
|
|
45
43
|
}
|
|
46
44
|
} as const
|
|
47
45
|
export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
|
|
48
|
-
export const ${camelName}DataValidator =
|
|
49
|
-
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
|
|
47
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({})
|
|
48
|
+
|
|
49
|
+
// Schema for updating existing data
|
|
50
|
+
export const ${camelName}PatchSchema = {
|
|
51
|
+
$id: '${upperName}Patch',
|
|
52
|
+
type: 'object',
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
required: [],
|
|
55
|
+
properties: {
|
|
56
|
+
...${camelName}Schema.properties
|
|
57
|
+
}
|
|
58
|
+
} as const
|
|
59
|
+
export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
|
|
60
|
+
export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
|
|
61
|
+
export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({})
|
|
52
62
|
|
|
53
63
|
// Schema for allowed query properties
|
|
54
64
|
export const ${camelName}QuerySchema = {
|
|
@@ -61,9 +71,7 @@ export const ${camelName}QuerySchema = {
|
|
|
61
71
|
} as const
|
|
62
72
|
export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
|
|
63
73
|
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
64
|
-
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
65
|
-
properties: {}
|
|
66
|
-
})
|
|
74
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({})
|
|
67
75
|
`;
|
|
68
76
|
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'json', (0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
69
77
|
lib,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.json.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"schema.json.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AAGxD,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,GAAG,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