@pylonts/dsl 1.1.11 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/convert.d.ts +6 -8
  2. package/dist/curd.js +1 -1
  3. package/dist/dao.d.ts +10 -7
  4. package/dist/dao.js +20 -7
  5. package/dist/dsl.d.ts +18 -1
  6. package/dist/dsl.js +40 -0
  7. package/dist/dto.d.ts +13 -8
  8. package/dist/dto.js +68 -13
  9. package/dist/entity.d.ts +4 -3
  10. package/dist/entity.js +1 -1
  11. package/dist/filter.d.ts +6 -4
  12. package/dist/filter.js +1 -1
  13. package/dist/flow-script.js +8 -2
  14. package/dist/flow.d.ts +10 -2
  15. package/dist/flow.js +44 -4
  16. package/dist/mermaid-driver.js +2 -2
  17. package/dist/project.d.ts +5 -2
  18. package/dist/project.js +21 -2
  19. package/dist/service.d.ts +13 -8
  20. package/dist/service.js +1 -1
  21. package/dist/third-service.d.ts +10 -53
  22. package/dist/third-service.js +3 -78
  23. package/dist/typebox-driver.d.ts +0 -6
  24. package/dist/typebox-driver.js +8 -36
  25. package/dist/utils.d.ts +2 -2
  26. package/docs/curd.md +55 -20
  27. package/docs/dao-generation.md +477 -477
  28. package/docs/project.md +32 -24
  29. package/docs/token.md +326 -326
  30. package/package.json +1 -1
  31. package/src/action.ts +51 -51
  32. package/src/controller.ts +53 -53
  33. package/src/convert.ts +76 -78
  34. package/src/curd.ts +104 -104
  35. package/src/dao.ts +504 -485
  36. package/src/dsl.ts +296 -257
  37. package/src/dto.ts +323 -266
  38. package/src/entity.ts +43 -42
  39. package/src/expr.ts +64 -64
  40. package/src/filter.ts +71 -69
  41. package/src/flow-script.ts +702 -695
  42. package/src/flow.ts +1272 -1226
  43. package/src/index.ts +46 -46
  44. package/src/mermaid-driver.ts +339 -339
  45. package/src/mysql-driver.ts +108 -108
  46. package/src/project.ts +138 -114
  47. package/src/service.ts +112 -107
  48. package/src/third-service.ts +68 -191
  49. package/src/typebox-driver.ts +234 -268
  50. package/src/utils.ts +74 -74
package/src/utils.ts CHANGED
@@ -1,75 +1,75 @@
1
- import type { Field, SchemaBase } from './dsl.js';
2
- import type { FrontAppSchema, ProjectApiSchema } from './project.js';
3
-
4
- // Base utility modules — business-agnostic helpers with full method
5
- // signatures (e.g. DateTimeUtils.format). Called at the service layer;
6
- // their args/results are own wire types, independent of business schemas.
7
-
8
- /** A utility method with a full signature. */
9
- export interface UtilsMethodSchema extends SchemaBase {
10
- type: 'utilsMethod';
11
- /** The utility module this method belongs to. */
12
- schema: UtilsSchema;
13
- /** Input fields. */
14
- args: Record<string, Field>;
15
- /** Output field. */
16
- result: Field;
17
- }
18
-
19
- /** Method input for defineUtils: type/schema/name are set by the builder. */
20
- export type UtilsMethodDef = Omit<UtilsMethodSchema, 'type' | 'schema' | 'name'>;
21
-
22
- /** A base utility module (e.g. DateTimeUtils). */
23
- export interface UtilsSchema extends SchemaBase {
24
- type: 'utils';
25
- /** Backend binding — the api module this utils belongs to (shared instance
26
- * from project.config.ts apis). With `app` it serves that frontend
27
- * ({api}/{app}/utils/); alone it is the api's public module
28
- * ({api}/common/utils/). Unset = not backend-side. */
29
- api?: ProjectApiSchema;
30
- /** Optional binding — the frontend app this utils serves (shared instance
31
- * from project.config.ts apps). Empty means a shared public module. */
32
- app?: FrontAppSchema;
33
- /** Methods keyed by name — the map key is written back as the method name. */
34
- methods: Record<string, UtilsMethodSchema>;
35
- }
36
-
37
- export function defineUtils(options: {
38
- name: string;
39
- api?: ProjectApiSchema;
40
- app?: FrontAppSchema;
41
- methods: Record<string, UtilsMethodDef>;
42
- description?: string;
43
- }): UtilsSchema {
44
- if (options.api !== undefined && options.app !== undefined && !options.api.apps.includes(options.app)) {
45
- throw new Error(`utils ${options.name}: api '${options.api.name}' does not serve app '${options.app.name}'`);
46
- }
47
- const schema: UtilsSchema = {
48
- type: 'utils',
49
- name: options.name,
50
- description: options.description,
51
- api: options.api,
52
- app: options.app,
53
- methods: {},
54
- };
55
- for (const key of Object.keys(options.methods)) {
56
- const method = options.methods[key] as UtilsMethodDef;
57
- const methodSchema: UtilsMethodSchema = {
58
- type: 'utilsMethod',
59
- name: key,
60
- description: method.description,
61
- schema,
62
- args: method.args,
63
- result: method.result,
64
- };
65
- for (const argKey of Object.keys(methodSchema.args)) {
66
- const field = methodSchema.args[argKey] as Field;
67
- field.name = argKey;
68
- field.schema = methodSchema;
69
- }
70
- methodSchema.result.name = key;
71
- methodSchema.result.schema = methodSchema;
72
- schema.methods[key] = methodSchema;
73
- }
74
- return schema;
1
+ import type { CollectionSchemaBase, Field, SchemaBase } from './dsl.js';
2
+ import type { FrontAppSchema, ProjectApiSchema } from './project.js';
3
+
4
+ // Base utility modules — business-agnostic helpers with full method
5
+ // signatures (e.g. DateTimeUtils.format). Called at the service layer;
6
+ // their args/results are own wire types, independent of business schemas.
7
+
8
+ /** A utility method with a full signature. */
9
+ export interface UtilsMethodSchema extends SchemaBase {
10
+ type: 'utilsMethod';
11
+ /** The utility module this method belongs to. */
12
+ schema: UtilsSchema;
13
+ /** Input fields. */
14
+ args: Record<string, Field>;
15
+ /** Output field. */
16
+ result: Field;
17
+ }
18
+
19
+ /** Method input for defineUtils: type/schema/name are set by the builder. */
20
+ export type UtilsMethodDef = Omit<UtilsMethodSchema, 'type' | 'schema' | 'name'>;
21
+
22
+ /** A base utility module (e.g. DateTimeUtils). */
23
+ export interface UtilsSchema extends CollectionSchemaBase {
24
+ type: 'utils';
25
+ /** Backend binding — the api module this utils belongs to (shared instance
26
+ * from project.config.ts apis). With `app` it serves that frontend
27
+ * ({api}/{app}/utils/); alone it is the api's public module
28
+ * ({api}/common/utils/). Unset = not backend-side. */
29
+ api?: ProjectApiSchema;
30
+ /** Optional binding — the frontend app this utils serves (shared instance
31
+ * from project.config.ts apps). Empty means a shared public module. */
32
+ app?: FrontAppSchema;
33
+ /** Methods keyed by name — the map key is written back as the method name. */
34
+ methods: Record<string, UtilsMethodSchema>;
35
+ }
36
+
37
+ export function defineUtils(options: {
38
+ name: string;
39
+ api?: ProjectApiSchema;
40
+ app?: FrontAppSchema;
41
+ methods: Record<string, UtilsMethodDef>;
42
+ description?: string;
43
+ }): UtilsSchema {
44
+ if (options.api !== undefined && options.app !== undefined && !options.api.apps.includes(options.app)) {
45
+ throw new Error(`utils ${options.name}: api '${options.api.name}' does not serve app '${options.app.name}'`);
46
+ }
47
+ const schema: UtilsSchema = {
48
+ type: 'utils',
49
+ name: options.name,
50
+ description: options.description,
51
+ api: options.api,
52
+ app: options.app,
53
+ methods: {},
54
+ };
55
+ for (const key of Object.keys(options.methods)) {
56
+ const method = options.methods[key] as UtilsMethodDef;
57
+ const methodSchema: UtilsMethodSchema = {
58
+ type: 'utilsMethod',
59
+ name: key,
60
+ description: method.description,
61
+ schema,
62
+ args: method.args,
63
+ result: method.result,
64
+ };
65
+ for (const argKey of Object.keys(methodSchema.args)) {
66
+ const field = methodSchema.args[argKey] as Field;
67
+ field.name = argKey;
68
+ field.schema = methodSchema;
69
+ }
70
+ methodSchema.result.name = key;
71
+ methodSchema.result.schema = methodSchema;
72
+ schema.methods[key] = methodSchema;
73
+ }
74
+ return schema;
75
75
  }