@kollors/deep-json-server 0.7.0 → 0.8.1

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 +19 -16
  2. package/README.ru.md +20 -17
  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/{src → dist/src}/constants.js +1 -0
  16. package/dist/src/constants.js.map +1 -0
  17. package/dist/src/database.d.ts +20 -0
  18. package/dist/src/database.js +136 -0
  19. package/dist/src/database.js.map +1 -0
  20. package/dist/src/files/contract.d.ts +67 -0
  21. package/dist/src/files/contract.js +106 -0
  22. package/dist/src/files/contract.js.map +1 -0
  23. package/dist/src/files/disk-store.d.ts +5 -0
  24. package/dist/src/files/disk-store.js +313 -0
  25. package/dist/src/files/disk-store.js.map +1 -0
  26. package/dist/src/files/index.d.ts +5 -0
  27. package/dist/src/files/index.js +6 -0
  28. package/dist/src/files/index.js.map +1 -0
  29. package/dist/src/files/memory-store.d.ts +3 -0
  30. package/dist/src/files/memory-store.js +80 -0
  31. package/dist/src/files/memory-store.js.map +1 -0
  32. package/dist/src/files/routes.d.ts +6 -0
  33. package/dist/src/files/routes.js +77 -0
  34. package/dist/src/files/routes.js.map +1 -0
  35. package/dist/src/openapi/config.d.ts +11 -0
  36. package/dist/src/openapi/config.js +204 -0
  37. package/dist/src/openapi/config.js.map +1 -0
  38. package/dist/src/openapi/document.d.ts +9 -0
  39. package/dist/src/openapi/document.js +338 -0
  40. package/dist/src/openapi/document.js.map +1 -0
  41. package/dist/src/openapi/index.d.ts +10 -0
  42. package/dist/src/openapi/index.js +27 -0
  43. package/dist/src/openapi/index.js.map +1 -0
  44. package/dist/src/openapi/inference.d.ts +14 -0
  45. package/dist/src/openapi/inference.js +145 -0
  46. package/dist/src/openapi/inference.js.map +1 -0
  47. package/dist/src/query/filter.d.ts +6 -0
  48. package/dist/src/query/filter.js +248 -0
  49. package/dist/src/query/filter.js.map +1 -0
  50. package/{src → dist/src}/query/index.js +1 -0
  51. package/dist/src/query/index.js.map +1 -0
  52. package/dist/src/query/pagination.d.ts +11 -0
  53. package/dist/src/query/pagination.js +28 -0
  54. package/dist/src/query/pagination.js.map +1 -0
  55. package/dist/src/query/sort.d.ts +1 -0
  56. package/dist/src/query/sort.js +54 -0
  57. package/dist/src/query/sort.js.map +1 -0
  58. package/dist/src/relation-metadata.d.ts +10 -0
  59. package/dist/src/relation-metadata.js +32 -0
  60. package/dist/src/relation-metadata.js.map +1 -0
  61. package/dist/src/relations.d.ts +12 -0
  62. package/dist/src/relations.js +155 -0
  63. package/dist/src/relations.js.map +1 -0
  64. package/dist/src/server.d.ts +13 -0
  65. package/dist/src/server.js +188 -0
  66. package/dist/src/server.js.map +1 -0
  67. package/dist/src/types.d.ts +52 -0
  68. package/dist/src/types.js +2 -0
  69. package/dist/src/types.js.map +1 -0
  70. package/dist/src/utils.d.ts +20 -0
  71. package/dist/src/utils.js +63 -0
  72. package/dist/src/utils.js.map +1 -0
  73. package/package.json +17 -16
  74. package/bin/deep-json-server.js +0 -11
  75. package/index.js +0 -12
  76. package/src/cli.js +0 -91
  77. package/src/config.js +0 -203
  78. package/src/database.js +0 -148
  79. package/src/files.js +0 -633
  80. package/src/openapi/config.js +0 -124
  81. package/src/openapi/document.js +0 -394
  82. package/src/openapi/index.js +0 -36
  83. package/src/openapi/inference.js +0 -187
  84. package/src/query/filter.js +0 -283
  85. package/src/query/pagination.js +0 -44
  86. package/src/query/sort.js +0 -63
  87. package/src/relation-metadata.js +0 -41
  88. package/src/relations.js +0 -173
  89. package/src/server.js +0 -250
  90. package/src/utils.js +0 -84
  91. package/types/index.d.ts +0 -21
  92. package/types/src/config.d.ts +0 -73
  93. package/types/src/database.d.ts +0 -33
  94. package/types/src/files.d.ts +0 -64
  95. package/types/src/openapi/config.d.ts +0 -3
  96. package/types/src/openapi/document.d.ts +0 -11
  97. package/types/src/openapi/index.d.ts +0 -9
  98. package/types/src/openapi/inference.d.ts +0 -9
  99. package/types/src/query/filter.d.ts +0 -3
  100. package/types/src/query/pagination.d.ts +0 -8
  101. package/types/src/query/sort.d.ts +0 -1
  102. package/types/src/relation-metadata.d.ts +0 -9
  103. package/types/src/relations.d.ts +0 -3
  104. package/types/src/server.d.ts +0 -14
  105. package/types/src/utils.d.ts +0 -18
  106. /package/{types → dist}/src/constants.d.ts +0 -0
  107. /package/{types → dist}/src/query/index.d.ts +0 -0
@@ -1,64 +0,0 @@
1
- import { Readable } from 'node:stream';
2
- export type StoredFileMetadata = {
3
- directory: string;
4
- mimeType: string;
5
- name: string;
6
- };
7
- export type FileRecord = StoredFileMetadata & {
8
- size: number;
9
- };
10
- export type FileMetadata = FileRecord & {
11
- downloadUrl: string;
12
- metadataUrl: string;
13
- url: string;
14
- };
15
- export type FileUpload = {
16
- directory: string;
17
- maxFileSize: number;
18
- mimeType: string;
19
- name: string;
20
- override: boolean;
21
- stream: Readable;
22
- };
23
- export type FileUpdate = {
24
- directory?: string;
25
- name?: string;
26
- };
27
- export type FileStore = {
28
- /**
29
- * Returns file metadata and contents.
30
- */
31
- get: (path: string) => Promise<{
32
- file: FileRecord;
33
- stream: Readable;
34
- }>;
35
- /**
36
- * Returns file metadata.
37
- */
38
- metadata: (path: string) => Promise<FileRecord>;
39
- /**
40
- * Deletes a file.
41
- */
42
- remove: (path: string) => Promise<void>;
43
- /**
44
- * Renames or moves a file.
45
- */
46
- update: (path: string, update: FileUpdate) => Promise<FileRecord>;
47
- /**
48
- * Stores a file.
49
- */
50
- upload: (upload: FileUpload) => Promise<{
51
- created: boolean;
52
- file: FileRecord;
53
- }>;
54
- };
55
- /**
56
- * Creates a disk- or memory-backed file store with serialized operations.
57
- * @param {import('./config.js').FilesConfig} config File storage configuration.
58
- * @returns {Promise<FileStore>} File store.
59
- */
60
- export declare const createFileStore: (config: import('./config.js').FilesConfig) => Promise<FileStore>;
61
- export declare const registerFileRoutes: (fastify: any, { maxFileSize, store }: {
62
- maxFileSize: any;
63
- store: any;
64
- }) => 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 document without runtime server addresses.
3
- * @param {{ database: Record<string, Array<Record<string, unknown>>>, files?: boolean, maxPageSize?: number, schema?: Record<string, unknown> }} options Source data and schema settings.
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,14 +0,0 @@
1
- export type OpenapiDocument = Record<string, unknown>;
2
- export type ServerFacade = {
3
- fastify: () => import('fastify').FastifyInstance;
4
- openapi: () => Promise<OpenapiDocument>;
5
- };
6
- /**
7
- * Creates lazy Fastify and OpenAPI accessors from one configuration.
8
- * @param {import('./config.js').DeepJsonServerConfig} config Server configuration.
9
- * @param {{ files?: boolean }} [features] Optional feature switches.
10
- * @returns {Promise<ServerFacade>} Server facade.
11
- */
12
- export declare function createServer(config: import('./config.js').DeepJsonServerConfig, features?: {
13
- files?: boolean;
14
- }): Promise<ServerFacade>;
@@ -1,18 +0,0 @@
1
- export declare const createHttpError: (statusCode: any, message: any) => Error;
2
- /** @returns {<T>(operation: () => T | Promise<T>) => Promise<T>} Serialized operation scheduler. */
3
- export declare const createSerialQueue: () => <T>(operation: () => T | Promise<T>) => Promise<T>;
4
- /**
5
- * Creates a random ID that is not currently in use.
6
- * @param {(id: string) => boolean} isUsed Checks whether an ID already exists.
7
- * @returns {string} Unique ID.
8
- */
9
- export declare const createUniqueId: (isUsed: (id: string) => boolean) => string;
10
- export declare const getResourceNames: (data: any) => string[];
11
- export declare const isObject: (value: any) => boolean;
12
- export declare const isSafeKey: (key: any) => boolean;
13
- export declare const toArray: (value: any) => any[];
14
- export declare const isEqual: (left: any, right: any) => any;
15
- export declare const resolveDatabasePath: (databasePath: any) => any;
16
- export declare const isIdEqual: (left: any, right: any) => boolean;
17
- export declare const singularize: (value: any) => any;
18
- export declare const toPascalCase: (value: any) => any;
File without changes
File without changes