@kollors/deep-json-server 0.6.0 → 0.8.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 (107) hide show
  1. package/README.md +52 -20
  2. package/README.ru.md +52 -20
  3. package/dist/bin/deep-json-server.d.ts +2 -0
  4. package/dist/bin/deep-json-server.js +11 -0
  5. package/dist/bin/deep-json-server.js.map +1 -0
  6. package/dist/index.d.ts +5 -0
  7. package/dist/index.js +2 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/src/cli.d.ts +4 -0
  10. package/dist/src/cli.js +80 -0
  11. package/dist/src/cli.js.map +1 -0
  12. package/dist/src/config.d.ts +54 -0
  13. package/dist/src/config.js +145 -0
  14. package/dist/src/config.js.map +1 -0
  15. package/{types → dist}/src/constants.d.ts +1 -1
  16. package/{src → dist/src}/constants.js +2 -1
  17. package/dist/src/constants.js.map +1 -0
  18. package/dist/src/database.d.ts +20 -0
  19. package/dist/src/database.js +136 -0
  20. package/dist/src/database.js.map +1 -0
  21. package/dist/src/files/contract.d.ts +67 -0
  22. package/dist/src/files/contract.js +106 -0
  23. package/dist/src/files/contract.js.map +1 -0
  24. package/dist/src/files/disk-store.d.ts +5 -0
  25. package/dist/src/files/disk-store.js +313 -0
  26. package/dist/src/files/disk-store.js.map +1 -0
  27. package/dist/src/files/index.d.ts +5 -0
  28. package/dist/src/files/index.js +6 -0
  29. package/dist/src/files/index.js.map +1 -0
  30. package/dist/src/files/memory-store.d.ts +3 -0
  31. package/dist/src/files/memory-store.js +80 -0
  32. package/dist/src/files/memory-store.js.map +1 -0
  33. package/dist/src/files/routes.d.ts +6 -0
  34. package/dist/src/files/routes.js +77 -0
  35. package/dist/src/files/routes.js.map +1 -0
  36. package/dist/src/openapi/config.d.ts +11 -0
  37. package/dist/src/openapi/config.js +204 -0
  38. package/dist/src/openapi/config.js.map +1 -0
  39. package/dist/src/openapi/document.d.ts +9 -0
  40. package/dist/src/openapi/document.js +338 -0
  41. package/dist/src/openapi/document.js.map +1 -0
  42. package/dist/src/openapi/index.d.ts +10 -0
  43. package/dist/src/openapi/index.js +27 -0
  44. package/dist/src/openapi/index.js.map +1 -0
  45. package/dist/src/openapi/inference.d.ts +14 -0
  46. package/dist/src/openapi/inference.js +145 -0
  47. package/dist/src/openapi/inference.js.map +1 -0
  48. package/dist/src/query/filter.d.ts +6 -0
  49. package/dist/src/query/filter.js +248 -0
  50. package/dist/src/query/filter.js.map +1 -0
  51. package/{src → dist/src}/query/index.js +1 -0
  52. package/dist/src/query/index.js.map +1 -0
  53. package/dist/src/query/pagination.d.ts +11 -0
  54. package/dist/src/query/pagination.js +28 -0
  55. package/dist/src/query/pagination.js.map +1 -0
  56. package/dist/src/query/sort.d.ts +1 -0
  57. package/dist/src/query/sort.js +54 -0
  58. package/dist/src/query/sort.js.map +1 -0
  59. package/dist/src/relation-metadata.d.ts +10 -0
  60. package/dist/src/relation-metadata.js +32 -0
  61. package/dist/src/relation-metadata.js.map +1 -0
  62. package/dist/src/relations.d.ts +12 -0
  63. package/dist/src/relations.js +155 -0
  64. package/dist/src/relations.js.map +1 -0
  65. package/dist/src/server.d.ts +13 -0
  66. package/dist/src/server.js +188 -0
  67. package/dist/src/server.js.map +1 -0
  68. package/dist/src/types.d.ts +52 -0
  69. package/dist/src/types.js +2 -0
  70. package/dist/src/types.js.map +1 -0
  71. package/dist/src/utils.d.ts +20 -0
  72. package/dist/src/utils.js +63 -0
  73. package/dist/src/utils.js.map +1 -0
  74. package/package.json +24 -16
  75. package/bin/deep-json-server.js +0 -11
  76. package/index.js +0 -7
  77. package/src/cli.js +0 -91
  78. package/src/config.js +0 -194
  79. package/src/database.js +0 -157
  80. package/src/files.js +0 -368
  81. package/src/openapi/config.js +0 -124
  82. package/src/openapi/document.js +0 -317
  83. package/src/openapi/index.js +0 -36
  84. package/src/openapi/inference.js +0 -187
  85. package/src/query/filter.js +0 -282
  86. package/src/query/pagination.js +0 -44
  87. package/src/query/sort.js +0 -63
  88. package/src/relation-metadata.js +0 -40
  89. package/src/relations.js +0 -173
  90. package/src/server.js +0 -248
  91. package/src/utils.js +0 -54
  92. package/types/index.d.ts +0 -11
  93. package/types/src/config.d.ts +0 -86
  94. package/types/src/database.d.ts +0 -11
  95. package/types/src/files.d.ts +0 -24
  96. package/types/src/openapi/config.d.ts +0 -3
  97. package/types/src/openapi/document.d.ts +0 -11
  98. package/types/src/openapi/index.d.ts +0 -9
  99. package/types/src/openapi/inference.d.ts +0 -9
  100. package/types/src/query/filter.d.ts +0 -3
  101. package/types/src/query/pagination.d.ts +0 -8
  102. package/types/src/query/sort.d.ts +0 -1
  103. package/types/src/relation-metadata.d.ts +0 -9
  104. package/types/src/relations.d.ts +0 -3
  105. package/types/src/server.d.ts +0 -13
  106. package/types/src/utils.d.ts +0 -10
  107. /package/{types → dist}/src/query/index.d.ts +0 -0
package/src/server.js DELETED
@@ -1,248 +0,0 @@
1
- import Fastify from 'fastify';
2
- import { normalizeServerConfig } from './config.js';
3
- import { DEFAULT_HOST, DEFAULT_MAX_FILE_SIZE, DEFAULT_PORT, MAX_PAGE_SIZE } from './constants.js';
4
- import { createDatabaseStore, createId, findItem, getCollection } from './database.js';
5
- import { createFileStore, registerFileRoutes } from './files.js';
6
- import { resolveSchemaConfig } from './openapi/config.js';
7
- import { buildOpenapiDocument } from './openapi/document.js';
8
- import { createOpenapi, writeOpenapi } from './openapi/index.js';
9
- import { matchesWhere, paginateItems, parsePagination, parseWhere, sortItems, validateWhere } from './query/index.js';
10
- import { embedItem, parseEmbedPaths, validateEmbedPaths } from './relations.js';
11
- import { createHttpError, getResourceNames, isObject } from './utils.js';
12
-
13
- /** @typedef {Record<string, unknown>} OpenapiDocument */
14
-
15
- const CORS_HEADERS = {
16
- 'Access-Control-Allow-Headers': 'Content-Name, Content-Type',
17
- 'Access-Control-Allow-Methods': 'DELETE, GET, OPTIONS, PATCH, POST, PUT',
18
- 'Access-Control-Allow-Origin': '*',
19
- };
20
-
21
- const getRequestBody = (body) => {
22
- if (!isObject(body)) {
23
- throw createHttpError(400, 'Тело запроса должно быть JSON-объектом');
24
- }
25
-
26
- return body;
27
- };
28
-
29
- const getSchemaName = (reference) => reference.split('/').at(-1);
30
-
31
- const addRequestSchemas = (server, document, resources) => {
32
- const requestSchemaNames = new Set(
33
- resources.flatMap((resource) => {
34
- const resourcePath = document.paths[`/${resource}`];
35
- const itemPath = document.paths[`/${resource}/{id}`];
36
-
37
- return [getSchemaName(resourcePath.post.requestBody.content['application/json'].schema.$ref), getSchemaName(itemPath.patch.requestBody.content['application/json'].schema.$ref)];
38
- }),
39
- );
40
-
41
- requestSchemaNames.forEach((schemaName) => {
42
- server.addSchema({ $id: schemaName, ...document.components.schemas[schemaName] });
43
- });
44
- };
45
-
46
- const registerResourceRoutes = (server, store, resource, document, maxPageSize) => {
47
- const resourcePath = `/${resource}`;
48
- const itemPath = `/${resource}/:id`;
49
- const createSchemaName = getSchemaName(document.paths[resourcePath].post.requestBody.content['application/json'].schema.$ref);
50
- const updateSchemaName = getSchemaName(document.paths[`/${resource}/{id}`].patch.requestBody.content['application/json'].schema.$ref);
51
-
52
- server.get(resourcePath, async (request) => {
53
- const collection = getCollection(store.database, resource);
54
- const where = parseWhere(request.query);
55
- const embedPaths = parseEmbedPaths(request.query._embed);
56
- const pagination = parsePagination(request.query, maxPageSize);
57
-
58
- validateEmbedPaths(store.database, resource, collection, embedPaths);
59
-
60
- const relationIndexes = new Map();
61
- const embeddedItems = collection.map((item) => embedItem(store.database, item, resource, embedPaths, relationIndexes));
62
-
63
- validateWhere(where, embeddedItems);
64
-
65
- const filteredItems = embeddedItems.filter((item) => matchesWhere(item, where));
66
- const sortedItems = sortItems(filteredItems, request.query._sort, embeddedItems);
67
-
68
- return paginateItems(sortedItems, pagination.page, pagination.pageSize);
69
- });
70
-
71
- server.get(itemPath, async (request) => {
72
- const collection = getCollection(store.database, resource);
73
- const item = findItem(collection, request.params.id);
74
- const embedPaths = parseEmbedPaths(request.query._embed);
75
-
76
- if (item == null) {
77
- throw createHttpError(404, 'Запись не найдена');
78
- }
79
-
80
- validateEmbedPaths(store.database, resource, collection, embedPaths);
81
-
82
- return embedItem(store.database, item, resource, embedPaths);
83
- });
84
-
85
- server.post(resourcePath, { schema: { body: { $ref: `${createSchemaName}#` } } }, async (request, reply) => {
86
- const item = await store.update((database) => {
87
- const collection = getCollection(database, resource);
88
- const createdItem = { ...getRequestBody(request.body), id: createId(collection) };
89
-
90
- collection.push(createdItem);
91
-
92
- return createdItem;
93
- });
94
-
95
- return reply.code(201).send(item);
96
- });
97
-
98
- server.put(itemPath, { schema: { body: { $ref: `${createSchemaName}#` } } }, async (request) =>
99
- store.update((database) => {
100
- const collection = getCollection(database, resource);
101
- const currentItem = findItem(collection, request.params.id);
102
-
103
- if (currentItem == null) {
104
- throw createHttpError(404, 'Запись не найдена');
105
- }
106
-
107
- const item = { ...getRequestBody(request.body), id: currentItem.id };
108
-
109
- collection.splice(collection.indexOf(currentItem), 1, item);
110
-
111
- return item;
112
- }),
113
- );
114
-
115
- server.patch(itemPath, { schema: { body: { $ref: `${updateSchemaName}#` } } }, async (request) =>
116
- store.update((database) => {
117
- const collection = getCollection(database, resource);
118
- const currentItem = findItem(collection, request.params.id);
119
-
120
- if (currentItem == null) {
121
- throw createHttpError(404, 'Запись не найдена');
122
- }
123
-
124
- const item = { ...currentItem, ...getRequestBody(request.body), id: currentItem.id };
125
-
126
- collection.splice(collection.indexOf(currentItem), 1, item);
127
-
128
- return item;
129
- }),
130
- );
131
-
132
- server.delete(itemPath, async (request) =>
133
- store.update((database) => {
134
- const collection = getCollection(database, resource);
135
- const currentItem = findItem(collection, request.params.id);
136
-
137
- if (currentItem == null) {
138
- throw createHttpError(404, 'Запись не найдена');
139
- }
140
-
141
- collection.splice(collection.indexOf(currentItem), 1);
142
-
143
- return currentItem;
144
- }),
145
- );
146
- };
147
-
148
- /**
149
- * Creates a Deep JSON Server facade.
150
- * @param {import('./config.js').DeepJsonServerConfig} options Server options.
151
- * @param {{ files?: boolean }} [features] Optional feature switches.
152
- * @returns {Promise<{ fastify: () => import('fastify').FastifyInstance, openapi: () => Promise<OpenapiDocument> }>} Server facade.
153
- */
154
- export async function createServer(options, features = {}) {
155
- const config = normalizeServerConfig(options);
156
- const filesEnabled = features.files ?? config.files != null;
157
- const { logger = true, maxFileSize = DEFAULT_MAX_FILE_SIZE, maxPageSize = MAX_PAGE_SIZE } = config.server;
158
- const store = await createDatabaseStore(config.database);
159
- const schema = await resolveSchemaConfig(config.database.schema);
160
- const fileStore = filesEnabled && config.files != null ? await createFileStore(config.files) : undefined;
161
- let fastifyInstance;
162
-
163
- if (filesEnabled && config.files == null) {
164
- throw new Error('Для файловых маршрутов укажите секцию config.files');
165
- }
166
-
167
- const buildDocument = () =>
168
- buildOpenapiDocument({
169
- database: store.database.data,
170
- files: filesEnabled,
171
- maxPageSize,
172
- schema,
173
- });
174
-
175
- const fastify = () => {
176
- if (fastifyInstance != null) {
177
- return fastifyInstance;
178
- }
179
-
180
- const document = buildDocument();
181
- const resources = getResourceNames(store.database.data);
182
- const server = Fastify({ logger });
183
- const listen = server.listen.bind(server);
184
-
185
- server.listen = (...args) => listen(...(args.length === 0 ? [{ host: config.server.host ?? DEFAULT_HOST, port: config.server.port ?? DEFAULT_PORT }] : args));
186
-
187
- addRequestSchemas(server, document, resources);
188
-
189
- server.addHook('onRequest', async (_request, reply) => {
190
- Object.entries(CORS_HEADERS).forEach(([header, value]) => {
191
- reply.header(header, value);
192
- });
193
- });
194
-
195
- server.addHook('preHandler', async (request) => {
196
- if (request.method === 'GET') {
197
- await store.read();
198
- }
199
- });
200
-
201
- server.options('/', async (_request, reply) => reply.code(204).send());
202
- server.options('/*', async (_request, reply) => reply.code(204).send());
203
- server.get('/', async () => ({ resources }));
204
-
205
- resources.forEach((resource) => {
206
- registerResourceRoutes(server, store, resource, document, maxPageSize);
207
- });
208
-
209
- if (fileStore != null) {
210
- registerFileRoutes(server, { maxFileSize, store: fileStore });
211
- }
212
-
213
- server.setErrorHandler((error, request, reply) => {
214
- const statusCode = Number.isInteger(error.statusCode) ? error.statusCode : 500;
215
-
216
- if (statusCode === 500) {
217
- request.log.error(error);
218
- }
219
-
220
- return reply.code(statusCode).send({ error: error.message });
221
- });
222
-
223
- fastifyInstance = server;
224
-
225
- return fastifyInstance;
226
- };
227
-
228
- const openapi = async () => {
229
- await store.read();
230
-
231
- const document = createOpenapi({
232
- database: store.database.data,
233
- files: filesEnabled,
234
- host: config.server.host,
235
- maxPageSize,
236
- port: config.server.port,
237
- schema,
238
- });
239
-
240
- if (config.openapi.path != null) {
241
- await writeOpenapi(document, config.openapi.path);
242
- }
243
-
244
- return document;
245
- };
246
-
247
- return { fastify, openapi };
248
- }
package/src/utils.js DELETED
@@ -1,54 +0,0 @@
1
- import { resolve } from 'node:path';
2
- import pluralize from 'pluralize';
3
-
4
- const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
5
-
6
- export const createHttpError = (statusCode, message) => {
7
- const error = new Error(message);
8
-
9
- error.statusCode = statusCode;
10
-
11
- return error;
12
- };
13
-
14
- export const getResourceNames = (data) => Object.keys(data);
15
- export const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
16
- export const isSafeKey = (key) => !UNSAFE_KEYS.has(key);
17
- export const toArray = (value) => (Array.isArray(value) ? value : [value]);
18
-
19
- export const isEqual = (left, right) => {
20
- if (Object.is(left, right)) {
21
- return true;
22
- }
23
-
24
- if (Array.isArray(left) && Array.isArray(right)) {
25
- return left.length === right.length && left.every((value, index) => isEqual(value, right[index]));
26
- }
27
-
28
- if (isObject(left) && isObject(right)) {
29
- const leftKeys = Object.keys(left);
30
- const rightKeys = Object.keys(right);
31
-
32
- return leftKeys.length === rightKeys.length && leftKeys.every((key) => isSafeKey(key) && Object.hasOwn(right, key) && isEqual(left[key], right[key]));
33
- }
34
-
35
- return false;
36
- };
37
-
38
- export const resolveDatabasePath = (databasePath) => {
39
- if (typeof databasePath !== 'string' || databasePath === '') {
40
- throw new Error('Укажите путь к JSON-базе данных');
41
- }
42
-
43
- return resolve(databasePath);
44
- };
45
-
46
- export const isIdEqual = (left, right) => left != null && right != null && String(left) === String(right);
47
- export const singularize = (value) => pluralize.singular(value);
48
-
49
- export const toPascalCase = (value) =>
50
- value
51
- .split(/[^a-zA-Z0-9]+/)
52
- .filter(Boolean)
53
- .map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)
54
- .join('');
package/types/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- /** @typedef {import('./src/config.js').DeepJsonServerConfig} DeepJsonServerConfig */
2
- /** @typedef {import('./src/config.js').DatabaseConfig} DatabaseConfig */
3
- /** @typedef {import('./src/config.js').FilesConfig} FilesConfig */
4
- /** @typedef {import('./src/config.js').MemoryFile} MemoryFile */
5
- /** @typedef {import('./src/server.js').OpenapiDocument} OpenapiDocument */
6
- export type DeepJsonServerConfig = import('./src/config.js').DeepJsonServerConfig;
7
- export type DatabaseConfig = import('./src/config.js').DatabaseConfig;
8
- export type FilesConfig = import('./src/config.js').FilesConfig;
9
- export type MemoryFile = import('./src/config.js').MemoryFile;
10
- export type OpenapiDocument = import('./src/server.js').OpenapiDocument;
11
- export { createServer } from './src/server.js';
@@ -1,86 +0,0 @@
1
- export type DatabaseData = Record<string, Array<Record<string, unknown>>>;
2
- export type DatabaseSchema = Record<string, unknown>;
3
- export type DatabaseConfig = {
4
- data: DatabaseData;
5
- path?: never;
6
- schema?: DatabaseSchema | string;
7
- } | {
8
- data?: never;
9
- path: string;
10
- schema?: DatabaseSchema | string;
11
- };
12
- export type MemoryFile = {
13
- content: Uint8Array;
14
- id: string;
15
- mimeType: string;
16
- name: string;
17
- };
18
- export type FilesConfig = {
19
- data: MemoryFile[];
20
- directory?: never;
21
- metadata?: never;
22
- } | {
23
- data?: never;
24
- directory: string;
25
- metadata: string;
26
- };
27
- export type DeepJsonServerConfig = {
28
- /**
29
- * Database source and optional schema.
30
- */
31
- database: DatabaseConfig;
32
- /**
33
- * Binary-file storage.
34
- */
35
- files?: FilesConfig;
36
- /**
37
- * Generated OpenAPI file.
38
- */
39
- openapi?: {
40
- path?: string;
41
- };
42
- /**
43
- * Runtime settings.
44
- */
45
- server?: {
46
- host?: string;
47
- logger?: boolean | Record<string, unknown>;
48
- maxFileSize?: number;
49
- maxPageSize?: number;
50
- port?: number;
51
- };
52
- };
53
- /**
54
- * @param {DeepJsonServerConfig} config Server configuration.
55
- * @param {string} [directoryPath] Base directory for relative paths.
56
- * @returns {{ database: DatabaseConfig, files?: FilesConfig, openapi: { path?: string }, server: { host?: string, logger?: boolean | Record<string, unknown>, maxFileSize?: number, maxPageSize?: number, port?: number } }} Normalized configuration.
57
- */
58
- export declare const normalizeServerConfig: (config: DeepJsonServerConfig, directoryPath?: string) => {
59
- database: DatabaseConfig;
60
- files?: FilesConfig;
61
- openapi: {
62
- path?: string;
63
- };
64
- server: {
65
- host?: string;
66
- logger?: boolean | Record<string, unknown>;
67
- maxFileSize?: number;
68
- maxPageSize?: number;
69
- port?: number;
70
- };
71
- };
72
- /** @param {string} configPath Configuration module path. */
73
- export declare function readServerConfig(configPath: string): Promise<{
74
- database: DatabaseConfig;
75
- files?: FilesConfig;
76
- openapi: {
77
- path?: string;
78
- };
79
- server: {
80
- host?: string;
81
- logger?: boolean | Record<string, unknown>;
82
- maxFileSize?: number;
83
- maxPageSize?: number;
84
- port?: number;
85
- };
86
- }>;
@@ -1,11 +0,0 @@
1
- export declare const validateDatabase: (data: any) => any;
2
- export declare const readJsonObject: (path: any, label: any) => Promise<any>;
3
- export declare const readDatabaseFile: (databasePath: any) => Promise<any>;
4
- /**
5
- * @param {import('./config.js').DatabaseConfig} config Database source.
6
- * @returns {Promise<any>} Internal database store.
7
- */
8
- export declare const createDatabaseStore: (config: import('./config.js').DatabaseConfig) => Promise<any>;
9
- export declare const getCollection: (database: any, resource: any) => any[];
10
- export declare const findItem: (collection: any, id: any) => any;
11
- export declare const createId: (collection: any) => any;
@@ -1,24 +0,0 @@
1
- /** @param {import('./config.js').FilesConfig} config File storage configuration. */
2
- export declare const createFileStore: (config: import('./config.js').FilesConfig) => Promise<{
3
- get: (id: any) => Promise<void>;
4
- remove: (id: any) => Promise<void>;
5
- upload: ({ maxFileSize, mimeType, name, stream }: {
6
- maxFileSize: any;
7
- mimeType: any;
8
- name: any;
9
- stream: any;
10
- }) => Promise<void>;
11
- } | {
12
- get: (id: any) => Promise<void>;
13
- remove: (id: any) => Promise<void>;
14
- upload: ({ maxFileSize, mimeType, name, stream }: {
15
- maxFileSize: any;
16
- mimeType: any;
17
- name: any;
18
- stream: any;
19
- }) => Promise<void>;
20
- }>;
21
- export declare const registerFileRoutes: (server: any, { maxFileSize, store }: {
22
- maxFileSize: any;
23
- store: any;
24
- }) => void;
@@ -1,3 +0,0 @@
1
- export declare const validateSchemaConfig: (schemaConfig: any, resources: any) => any;
2
- export declare const applyConfiguredFields: (schema: any, resource: any, resourceConfig: any) => any;
3
- export declare const resolveSchemaConfig: (schema: any) => Promise<any>;
@@ -1,11 +0,0 @@
1
- /**
2
- * Builds an OpenAPI 3.0 document from resolved server data.
3
- * @param {{ database: Record<string, Array<Record<string, unknown>>>, files?: boolean, maxPageSize?: number, schema?: Record<string, unknown> }} options Document options.
4
- * @returns {Record<string, unknown>} OpenAPI document.
5
- */
6
- export declare function buildOpenapiDocument(options: {
7
- database: Record<string, Array<Record<string, unknown>>>;
8
- files?: boolean;
9
- maxPageSize?: number;
10
- schema?: Record<string, unknown>;
11
- }): Record<string, unknown>;
@@ -1,9 +0,0 @@
1
- export declare const createOpenapi: ({ database, files, host, maxPageSize, port, schema }: {
2
- database: any;
3
- files: any;
4
- host?: string | undefined;
5
- maxPageSize: any;
6
- port?: number | undefined;
7
- schema: any;
8
- }) => Record<string, unknown>;
9
- export declare const writeOpenapi: (document: any, outputPath: any) => Promise<void>;
@@ -1,9 +0,0 @@
1
- export declare const mergeSchemas: (schemas: any) => any;
2
- export declare const mergeSchemaOverrides: (schema: any, overrides: any) => any;
3
- export declare const applyRequiredFields: (schema: any, path: any, requiredFields: any) => any;
4
- export declare const inferSchema: (values: any) => any;
5
- export declare function inferObjectSchema(values: any): any;
6
- export declare const ensureGeneratedIdSchema: (schema: any) => any;
7
- export declare const getSchemasAtPath: (schema: any, keys: any) => any;
8
- export declare const updateSchemasAtPath: (schema: any, keys: any, update: any) => any;
9
- export declare const omitId: (schema: any, keepRequired: any) => any;
@@ -1,3 +0,0 @@
1
- export declare function matchesWhere(value: any, where: any): any;
2
- export declare const parseWhere: (query: any) => any;
3
- export declare const validateWhere: (where: any, items: any, path?: string) => void;
@@ -1,8 +0,0 @@
1
- export declare const parsePagination: (query: any, maxPageSize?: number) => {
2
- page: any;
3
- pageSize: any;
4
- };
5
- export declare const paginateItems: (items: any, page: any, pageSize: any) => {
6
- data: any;
7
- total: any;
8
- };
@@ -1 +0,0 @@
1
- export declare const sortItems: (items: any, sort: any, validationItems?: any) => any[];
@@ -1,9 +0,0 @@
1
- export declare const getRelationKeys: (...names: any[]) => string[];
2
- export declare const resolveRelationResource: (resourceNames: any, relation: any, sourceResource: any) => any;
3
- export declare const getRelationMetadata: (key: any, resourceNames: any, sourceResource: any) => {
4
- isMany: boolean;
5
- relationName: any;
6
- reverseRelationName: any;
7
- sourceResource: any;
8
- targetResource: any;
9
- } | undefined;
@@ -1,3 +0,0 @@
1
- export declare const parseEmbedPaths: (embed: any) => any[];
2
- export declare const validateEmbedPaths: (database: any, resource: any, items: any, embedPaths: any) => void;
3
- export declare const embedItem: (database: any, item: any, resource: any, embedPaths: any, indexes?: Map<any, any>) => any;
@@ -1,13 +0,0 @@
1
- export type OpenapiDocument = Record<string, unknown>;
2
- /**
3
- * Creates a Deep JSON Server facade.
4
- * @param {import('./config.js').DeepJsonServerConfig} options Server options.
5
- * @param {{ files?: boolean }} [features] Optional feature switches.
6
- * @returns {Promise<{ fastify: () => import('fastify').FastifyInstance, openapi: () => Promise<OpenapiDocument> }>} Server facade.
7
- */
8
- export declare function createServer(options: import('./config.js').DeepJsonServerConfig, features?: {
9
- files?: boolean;
10
- }): Promise<{
11
- fastify: () => import('fastify').FastifyInstance;
12
- openapi: () => Promise<OpenapiDocument>;
13
- }>;
@@ -1,10 +0,0 @@
1
- export declare const createHttpError: (statusCode: any, message: any) => Error;
2
- export declare const getResourceNames: (data: any) => string[];
3
- export declare const isObject: (value: any) => boolean;
4
- export declare const isSafeKey: (key: any) => boolean;
5
- export declare const toArray: (value: any) => any[];
6
- export declare const isEqual: (left: any, right: any) => any;
7
- export declare const resolveDatabasePath: (databasePath: any) => any;
8
- export declare const isIdEqual: (left: any, right: any) => boolean;
9
- export declare const singularize: (value: any) => any;
10
- export declare const toPascalCase: (value: any) => any;
File without changes