@zenstackhq/server 3.0.0-beta.12 → 3.0.0-beta.14

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 (59) hide show
  1. package/dist/api.cjs +1767 -19
  2. package/dist/api.cjs.map +1 -1
  3. package/dist/api.d.cts +123 -4
  4. package/dist/api.d.ts +123 -4
  5. package/dist/api.js +1762 -15
  6. package/dist/api.js.map +1 -1
  7. package/dist/common-6DG-xEmM.d.cts +14 -0
  8. package/dist/common-CyapsM8n.d.ts +14 -0
  9. package/dist/elysia.cjs +118 -0
  10. package/dist/elysia.cjs.map +1 -0
  11. package/dist/elysia.d.cts +53 -0
  12. package/dist/elysia.d.ts +53 -0
  13. package/dist/elysia.js +83 -0
  14. package/dist/elysia.js.map +1 -0
  15. package/dist/express.cjs +41 -3
  16. package/dist/express.cjs.map +1 -1
  17. package/dist/express.d.cts +7 -7
  18. package/dist/express.d.ts +7 -7
  19. package/dist/express.js +30 -2
  20. package/dist/express.js.map +1 -1
  21. package/dist/fastify.cjs +103 -0
  22. package/dist/fastify.cjs.map +1 -0
  23. package/dist/fastify.d.cts +22 -0
  24. package/dist/fastify.d.ts +22 -0
  25. package/dist/fastify.js +68 -0
  26. package/dist/fastify.js.map +1 -0
  27. package/dist/hono.cjs +111 -0
  28. package/dist/hono.cjs.map +1 -0
  29. package/dist/hono.d.cts +18 -0
  30. package/dist/hono.d.ts +18 -0
  31. package/dist/hono.js +76 -0
  32. package/dist/hono.js.map +1 -0
  33. package/dist/next.cjs +178 -0
  34. package/dist/next.cjs.map +1 -0
  35. package/dist/next.d.cts +61 -0
  36. package/dist/next.d.ts +61 -0
  37. package/dist/next.js +143 -0
  38. package/dist/next.js.map +1 -0
  39. package/dist/nuxt.cjs +109 -0
  40. package/dist/nuxt.cjs.map +1 -0
  41. package/dist/nuxt.d.cts +19 -0
  42. package/dist/nuxt.d.ts +19 -0
  43. package/dist/nuxt.js +74 -0
  44. package/dist/nuxt.js.map +1 -0
  45. package/dist/sveltekit.cjs +134 -0
  46. package/dist/sveltekit.cjs.map +1 -0
  47. package/dist/sveltekit.d.cts +25 -0
  48. package/dist/sveltekit.d.ts +25 -0
  49. package/dist/sveltekit.js +99 -0
  50. package/dist/sveltekit.js.map +1 -0
  51. package/dist/tanstack-start.cjs +139 -0
  52. package/dist/tanstack-start.cjs.map +1 -0
  53. package/dist/tanstack-start.d.cts +32 -0
  54. package/dist/tanstack-start.d.ts +32 -0
  55. package/dist/tanstack-start.js +104 -0
  56. package/dist/tanstack-start.js.map +1 -0
  57. package/dist/{types-BH-88xJo.d.cts → types-D5t0sUEw.d.cts} +6 -2
  58. package/dist/{types-BH-88xJo.d.ts → types-D5t0sUEw.d.ts} +6 -2
  59. package/package.json +120 -8
package/dist/api.d.ts CHANGED
@@ -1,12 +1,130 @@
1
- import { SchemaDef } from '@zenstackhq/runtime/schema';
2
- import { A as ApiHandler, L as LogConfig, R as RequestContext, a as Response } from './types-BH-88xJo.js';
3
- import '@zenstackhq/runtime';
1
+ import { SchemaDef } from '@zenstackhq/orm/schema';
2
+ import { A as ApiHandler, L as LogConfig, R as RequestContext, a as Response } from './types-D5t0sUEw.js';
3
+ import '@zenstackhq/orm';
4
+
5
+ /**
6
+ * Options for {@link RestApiHandler}
7
+ */
8
+ type RestApiHandlerOptions<Schema extends SchemaDef = SchemaDef> = {
9
+ /**
10
+ * The schema
11
+ */
12
+ schema: Schema;
13
+ /**
14
+ * Logging configuration
15
+ */
16
+ log?: LogConfig;
17
+ /**
18
+ * The base endpoint of the RESTful API, must be a valid URL
19
+ */
20
+ endpoint: string;
21
+ /**
22
+ * The default page size for limiting the number of results returned
23
+ * from collection queries, including resource collection, related data
24
+ * of collection types, and relationship of collection types.
25
+ *
26
+ * Defaults to 100. Set to Infinity to disable pagination.
27
+ */
28
+ pageSize?: number;
29
+ /**
30
+ * The divider used to separate compound ID fields in the URL.
31
+ * Defaults to '_'.
32
+ */
33
+ idDivider?: string;
34
+ /**
35
+ * The charset used for URL segment values. Defaults to `a-zA-Z0-9-_~ %`. You can change it if your entity's ID values
36
+ * allow different characters. Specifically, if your models use compound IDs and the idDivider is set to a different value,
37
+ * it should be included in the charset.
38
+ */
39
+ urlSegmentCharset?: string;
40
+ modelNameMapping?: Record<string, string>;
41
+ externalIdMapping?: Record<string, string>;
42
+ };
43
+ /**
44
+ * RESTful-style API request handler (compliant with JSON:API)
45
+ */
46
+ declare class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Schema> {
47
+ private readonly options;
48
+ private serializers;
49
+ private readonly errors;
50
+ private filterParamPattern;
51
+ private createUpdatePayloadSchema;
52
+ private updateSingleRelationSchema;
53
+ private updateCollectionRelationSchema;
54
+ private upsertMetaSchema;
55
+ private typeMap;
56
+ private idDivider;
57
+ private urlPatternMap;
58
+ private modelNameMapping;
59
+ private reverseModelNameMapping;
60
+ private externalIdMapping;
61
+ constructor(options: RestApiHandlerOptions<Schema>);
62
+ get schema(): Schema;
63
+ get log(): LogConfig | undefined;
64
+ private buildUrlPatternMap;
65
+ private mapModelName;
66
+ private matchUrlPattern;
67
+ handleRequest({ client, method, path, query, requestBody }: RequestContext<Schema>): Promise<Response>;
68
+ private handleGenericError;
69
+ private processSingleRead;
70
+ private processFetchRelated;
71
+ private processReadRelationship;
72
+ private processCollectionRead;
73
+ private buildPartialSelect;
74
+ private addTotalCountToMeta;
75
+ private makePaginator;
76
+ private processRequestBody;
77
+ private processCreate;
78
+ private processUpsert;
79
+ private getUniqueFieldSets;
80
+ private processRelationshipCRUD;
81
+ private processUpdate;
82
+ private processDelete;
83
+ private requireModel;
84
+ private getIdFields;
85
+ private requireField;
86
+ private buildTypeMap;
87
+ private getModelInfo;
88
+ private makeLinkUrl;
89
+ private buildSerializers;
90
+ private getId;
91
+ private serializeItems;
92
+ private injectCompoundId;
93
+ private toPlainObject;
94
+ private replaceURLSearchParams;
95
+ private makeIdFilter;
96
+ private makeIdSelect;
97
+ private makeIdConnect;
98
+ private makeIdKey;
99
+ private makeDefaultIdKey;
100
+ private makeCompoundId;
101
+ private makeUpsertWhere;
102
+ private includeRelationshipIds;
103
+ private coerce;
104
+ private makeNormalizedUrl;
105
+ private getPagination;
106
+ private buildFilter;
107
+ private buildSort;
108
+ private buildRelationSelect;
109
+ private makeFilterValue;
110
+ private injectRelationQuery;
111
+ private handleZenStackError;
112
+ private makeError;
113
+ private makeUnsupportedModelError;
114
+ private makeUnsupportedRelationshipError;
115
+ }
4
116
 
5
117
  /**
6
118
  * Options for {@link RPCApiHandler}
7
119
  */
8
120
  type RPCApiHandlerOptions<Schema extends SchemaDef> = {
121
+ /**
122
+ * The schema
123
+ */
9
124
  schema: Schema;
125
+ /**
126
+ * Logging configuration
127
+ */
10
128
  log?: LogConfig;
11
129
  };
12
130
  /**
@@ -16,6 +134,7 @@ declare class RPCApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
16
134
  private readonly options;
17
135
  constructor(options: RPCApiHandlerOptions<Schema>);
18
136
  get schema(): Schema;
137
+ get log(): LogConfig | undefined;
19
138
  handleRequest({ client, method, path, query, requestBody }: RequestContext<Schema>): Promise<Response>;
20
139
  private isValidModel;
21
140
  private makeBadInputErrorResponse;
@@ -25,4 +144,4 @@ declare class RPCApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
25
144
  private unmarshalQ;
26
145
  }
27
146
 
28
- export { RPCApiHandler };
147
+ export { RPCApiHandler, type RPCApiHandlerOptions, RestApiHandler, type RestApiHandlerOptions };