@common-stack/server-core 8.0.1-alpha.0 → 8.2.1-alpha.0

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 (38) hide show
  1. package/LICENSE +34 -21
  2. package/lib/__tests__/connector-inngest-arrays.test.d.ts +1 -0
  3. package/lib/connector/connector.d.ts +93 -12
  4. package/lib/connector/connector.js +149 -14
  5. package/lib/connector/connector.js.map +1 -1
  6. package/lib/constants/directives.d.ts +1 -0
  7. package/lib/constants/directives.js +1 -0
  8. package/lib/constants/directives.js.map +1 -0
  9. package/lib/constants/index.d.ts +1 -0
  10. package/lib/index.d.ts +1 -0
  11. package/lib/index.js +1 -1
  12. package/lib/interfaces/connector.d.ts +3 -7
  13. package/lib/interfaces/roles.d.ts +2 -2
  14. package/lib/moleculer-generation/__tests__/integration-proxy-moleculer.test.d.ts +6 -0
  15. package/lib/moleculer-generation/__tests__/moleculerEventHandler.test.d.ts +5 -0
  16. package/lib/moleculer-generation/__tests__/serviceGenerationUtils.test.d.ts +5 -0
  17. package/lib/moleculer-generation/__tests__/typedMoleculerService.test.d.ts +5 -0
  18. package/lib/moleculer-generation/__tests__/typedProxyService.test.d.ts +5 -0
  19. package/lib/moleculer-generation/index.d.ts +16 -0
  20. package/lib/moleculer-generation/moleculerEventHandler.d.ts +73 -0
  21. package/lib/moleculer-generation/serviceGenerationUtils.d.ts +100 -0
  22. package/lib/moleculer-generation/typedMoleculerService.d.ts +502 -0
  23. package/lib/moleculer-generation/typedProxyService.d.ts +119 -0
  24. package/lib/moleculer-generation/zodToMoleculer.d.ts +45 -0
  25. package/lib/utils/extract-tenant-id.d.ts +1 -0
  26. package/lib/utils/extract-tenant-id.js +4 -0
  27. package/lib/utils/extract-tenant-id.js.map +1 -0
  28. package/lib/utils/generate-query-cache-key.d.ts +11 -0
  29. package/lib/utils/generate-query-cache-key.js +13 -0
  30. package/lib/utils/generate-query-cache-key.js.map +1 -0
  31. package/lib/utils/get-directive-args-from-schema.d.ts +13 -0
  32. package/lib/utils/get-directive-args-from-schema.js +25 -0
  33. package/lib/utils/get-directive-args-from-schema.js.map +1 -0
  34. package/lib/utils/index.d.ts +3 -0
  35. package/lib/utils/preferences.d.ts +1 -1
  36. package/package.json +5 -4
  37. package/lib/interfaces/connector.js +0 -5
  38. package/lib/interfaces/connector.js.map +0 -1
@@ -0,0 +1,13 @@
1
+ import {createHash}from'crypto';import {print}from'graphql/language/index.js';const generateQueryCacheKey = ({ query, variables, logger, userId, tenantId }) => {
2
+ const normalizedQuery = (typeof query === 'string' ? query : print(query)).trim();
3
+ const [, queryName] = normalizedQuery?.match(/{\s*(\w+)/) ?? [];
4
+ // Log the data right before hashing
5
+ if (logger) {
6
+ logger.trace('About to hash normalized query: [%s]', normalizedQuery);
7
+ logger.trace('About to hash variables: [%j]', variables);
8
+ }
9
+ const queryHash = createHash('sha256').update(normalizedQuery).digest('hex');
10
+ const variablesHash = variables ? createHash('sha256').update(JSON.stringify(variables)).digest('hex') : null;
11
+ const prefix = `${tenantId ? `${tenantId}:` : ''}${userId ? `${userId}:` : ''}`;
12
+ return `${prefix}${queryName}:${queryHash}${variablesHash ? `:${variablesHash}` : ''}`;
13
+ };export{generateQueryCacheKey};//# sourceMappingURL=generate-query-cache-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-query-cache-key.js","sources":["../../src/utils/generate-query-cache-key.ts"],"sourcesContent":[null],"names":[],"mappings":"8EAWa,MAAA,qBAAqB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAgC,KAAI;IAClH,MAAM,eAAe,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;AAClF,IAAA,MAAM,GAAG,SAAS,CAAC,GAAG,eAAe,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;;IAGhE,IAAI,MAAM,EAAE;AACR,QAAA,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,eAAe,CAAC,CAAC;AACtE,QAAA,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,SAAS,CAAC,CAAC;KAC5D;AAED,IAAA,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7E,IAAA,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAC9G,MAAM,MAAM,GAAG,CAAA,EAAG,QAAQ,GAAG,CAAG,EAAA,QAAQ,CAAG,CAAA,CAAA,GAAG,EAAE,CAAA,EAAG,MAAM,GAAG,CAAG,EAAA,MAAM,CAAG,CAAA,CAAA,GAAG,EAAE,CAAA,CAAE,CAAC;AAChF,IAAA,OAAO,GAAG,MAAM,CAAA,EAAG,SAAS,CAAI,CAAA,EAAA,SAAS,GAAG,aAAa,GAAG,CAAA,CAAA,EAAI,aAAa,CAAE,CAAA,GAAG,EAAE,EAAE,CAAC;AAC3F"}
@@ -0,0 +1,13 @@
1
+ import { GraphQLSchema, DocumentNode } from 'graphql';
2
+ type GetDirectiveArgsFromSchemaOptions = {
3
+ schema: GraphQLSchema;
4
+ directiveName: string;
5
+ } & ({
6
+ document: DocumentNode;
7
+ queryName?: never;
8
+ } | {
9
+ queryName: string;
10
+ document?: never;
11
+ });
12
+ export declare function getDirectiveArgsFromSchema({ schema, directiveName, document, queryName, }: GetDirectiveArgsFromSchemaOptions): any;
13
+ export {};
@@ -0,0 +1,25 @@
1
+ import {getDirective}from'@graphql-tools/utils';import {visit}from'graphql';function getDirectiveArgsFromSchema({ schema, directiveName, document, queryName, }) {
2
+ let directiveArgs = null;
3
+ const getDirectiveArgs = (value) => {
4
+ const queryType = schema.getQueryType();
5
+ if (!queryType)
6
+ return null;
7
+ const field = queryType.getFields()[value];
8
+ if (!field)
9
+ return null;
10
+ const [directive] = getDirective(schema, field, directiveName) ?? [];
11
+ return directive;
12
+ };
13
+ if (queryName) {
14
+ return getDirectiveArgs(queryName);
15
+ }
16
+ visit(document, {
17
+ OperationDefinition(node) {
18
+ const [firstSelection] = node.selectionSet.selections ?? []; // Get first field
19
+ if (firstSelection && 'name' in firstSelection) {
20
+ directiveArgs = getDirectiveArgs(firstSelection.name.value);
21
+ }
22
+ },
23
+ });
24
+ return directiveArgs;
25
+ }export{getDirectiveArgsFromSchema};//# sourceMappingURL=get-directive-args-from-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-directive-args-from-schema.js","sources":["../../src/utils/get-directive-args-from-schema.ts"],"sourcesContent":[null],"names":[],"mappings":"4EAWM,SAAU,0BAA0B,CAAC,EACvC,MAAM,EACN,aAAa,EACb,QAAQ,EACR,SAAS,GACuB,EAAA;IAChC,IAAI,aAAa,GAAG,IAAI,CAAC;AACzB,IAAA,MAAM,gBAAgB,GAAG,CAAC,KAAa,KAAI;AACvC,QAAA,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;AACxC,QAAA,IAAI,CAAC,SAAS;AAAE,YAAA,OAAO,IAAI,CAAC;QAE5B,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;AAC3C,QAAA,IAAI,CAAC,KAAK;AAAE,YAAA,OAAO,IAAI,CAAC;AAExB,QAAA,MAAM,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC;AACrE,QAAA,OAAO,SAAS,CAAC;AACrB,KAAC,CAAC;IACF,IAAI,SAAS,EAAE;AACX,QAAA,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;KACtC;IAED,KAAK,CAAC,QAAQ,EAAE;AACZ,QAAA,mBAAmB,CAAC,IAA6B,EAAA;AAC7C,YAAA,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,EAAE,CAAC;AAC5D,YAAA,IAAI,cAAc,IAAI,MAAM,IAAI,cAAc,EAAE;gBAC5C,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC/D;SACJ;AACJ,KAAA,CAAC,CAAC;AAEH,IAAA,OAAO,aAAa,CAAC;AACzB"}
@@ -1 +1,4 @@
1
1
  export * from './preferences';
2
+ export * from './generate-query-cache-key';
3
+ export * from './extract-tenant-id';
4
+ export * from './get-directive-args-from-schema';
@@ -1,6 +1,6 @@
1
1
  import { IPreferences, IOverwritePreference, IPreferencesData } from '../interfaces';
2
2
  export declare function getCurrentPreferences<T>(preferencesDefaultArr: IPreferences<T>[], overwritePreferences: IOverwritePreference[]): {
3
- [x: number]: IPreferences<T>;
3
+ [n: number]: IPreferences<T>;
4
4
  length: number;
5
5
  toString(): string;
6
6
  toLocaleString(): string;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@common-stack/server-core",
3
- "version": "8.0.1-alpha.0",
3
+ "version": "8.2.1-alpha.0",
4
4
  "description": "common core for higher packages to depend on",
5
- "license": "ISC",
5
+ "license": "UNLICENSED",
6
6
  "author": "CDMBase LLC",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",
@@ -24,7 +24,8 @@
24
24
  "watch": "yarn build:lib:watch"
25
25
  },
26
26
  "dependencies": {
27
- "@common-stack/core": "8.0.1-alpha.0"
27
+ "@common-stack/core": "8.2.1-alpha.0",
28
+ "zod": "^4.0.0"
28
29
  },
29
30
  "peerDependencies": {
30
31
  "@cdm-logger/core": ">=7.0.12",
@@ -36,5 +37,5 @@
36
37
  "typescript": {
37
38
  "definition": "lib/index.d.ts"
38
39
  },
39
- "gitHead": "73d9088ae254fbc43425eed5c9f5cd95bd66e921"
40
+ "gitHead": "b46db06f987271c3a2e050f081e266d3a01b285b"
40
41
  }
@@ -1,5 +0,0 @@
1
- var ConfigurationScope;
2
- (function (ConfigurationScope) {
3
- ConfigurationScope[ConfigurationScope["WINDOW"] = 1] = "WINDOW";
4
- ConfigurationScope[ConfigurationScope["RESOURCE"] = 2] = "RESOURCE";
5
- })(ConfigurationScope || (ConfigurationScope = {}));export{ConfigurationScope};//# sourceMappingURL=connector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector.js","sources":["../../src/interfaces/connector.ts"],"sourcesContent":[null],"names":[],"mappings":"IAQY,mBAGX;AAHD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAU,CAAA;AACV,IAAA,kBAAA,CAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAQ,CAAA;AACZ,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAG7B,EAAA,CAAA,CAAA"}