@strapi/database 5.58.0 → 5.59.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 (104) hide show
  1. package/dist/connection.d.ts.map +1 -1
  2. package/dist/connection.js +15 -2
  3. package/dist/connection.js.map +1 -1
  4. package/dist/connection.mjs +15 -2
  5. package/dist/connection.mjs.map +1 -1
  6. package/dist/dialects/sqlite/index.js +3 -3
  7. package/dist/dialects/sqlite/index.js.map +1 -1
  8. package/dist/dialects/sqlite/index.mjs +3 -3
  9. package/dist/dialects/sqlite/index.mjs.map +1 -1
  10. package/dist/entity-manager/regular-relations.js +1 -1
  11. package/dist/entity-manager/regular-relations.js.map +1 -1
  12. package/dist/entity-manager/regular-relations.mjs +1 -1
  13. package/dist/entity-manager/regular-relations.mjs.map +1 -1
  14. package/dist/index.d.ts +25 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +55 -13
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +44 -3
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/migrations/internal.d.ts.map +1 -1
  21. package/dist/migrations/internal.js +1 -0
  22. package/dist/migrations/internal.js.map +1 -1
  23. package/dist/migrations/internal.mjs +1 -0
  24. package/dist/migrations/internal.mjs.map +1 -1
  25. package/dist/migrations/runner.d.ts +2 -0
  26. package/dist/migrations/runner.d.ts.map +1 -1
  27. package/dist/migrations/runner.js +7 -2
  28. package/dist/migrations/runner.js.map +1 -1
  29. package/dist/migrations/runner.mjs +7 -2
  30. package/dist/migrations/runner.mjs.map +1 -1
  31. package/dist/migrations/users.d.ts.map +1 -1
  32. package/dist/migrations/users.js +1 -0
  33. package/dist/migrations/users.js.map +1 -1
  34. package/dist/migrations/users.mjs +1 -0
  35. package/dist/migrations/users.mjs.map +1 -1
  36. package/dist/pool-diagnostics/details.d.ts +58 -0
  37. package/dist/pool-diagnostics/details.d.ts.map +1 -0
  38. package/dist/pool-diagnostics/details.js +42 -0
  39. package/dist/pool-diagnostics/details.js.map +1 -0
  40. package/dist/pool-diagnostics/details.mjs +38 -0
  41. package/dist/pool-diagnostics/details.mjs.map +1 -0
  42. package/dist/pool-diagnostics/event-loop.d.ts +31 -0
  43. package/dist/pool-diagnostics/event-loop.d.ts.map +1 -0
  44. package/dist/pool-diagnostics/event-loop.js +59 -0
  45. package/dist/pool-diagnostics/event-loop.js.map +1 -0
  46. package/dist/pool-diagnostics/event-loop.mjs +54 -0
  47. package/dist/pool-diagnostics/event-loop.mjs.map +1 -0
  48. package/dist/pool-diagnostics/format.d.ts +9 -0
  49. package/dist/pool-diagnostics/format.d.ts.map +1 -0
  50. package/dist/pool-diagnostics/format.js +46 -0
  51. package/dist/pool-diagnostics/format.js.map +1 -0
  52. package/dist/pool-diagnostics/format.mjs +42 -0
  53. package/dist/pool-diagnostics/format.mjs.map +1 -0
  54. package/dist/pool-diagnostics/index.d.ts +33 -0
  55. package/dist/pool-diagnostics/index.d.ts.map +1 -0
  56. package/dist/pool-diagnostics/index.js +117 -0
  57. package/dist/pool-diagnostics/index.js.map +1 -0
  58. package/dist/pool-diagnostics/index.mjs +109 -0
  59. package/dist/pool-diagnostics/index.mjs.map +1 -0
  60. package/dist/pool-diagnostics/stack.d.ts +12 -0
  61. package/dist/pool-diagnostics/stack.d.ts.map +1 -0
  62. package/dist/pool-diagnostics/stack.js +46 -0
  63. package/dist/pool-diagnostics/stack.js.map +1 -0
  64. package/dist/pool-diagnostics/stack.mjs +44 -0
  65. package/dist/pool-diagnostics/stack.mjs.map +1 -0
  66. package/dist/query/helpers/populate/apply.d.ts.map +1 -1
  67. package/dist/query/helpers/populate/apply.js +21 -3
  68. package/dist/query/helpers/populate/apply.js.map +1 -1
  69. package/dist/query/helpers/populate/apply.mjs +21 -3
  70. package/dist/query/helpers/populate/apply.mjs.map +1 -1
  71. package/dist/query/helpers/streams/readable.d.ts +1 -1
  72. package/dist/query/helpers/streams/readable.d.ts.map +1 -1
  73. package/dist/query/helpers/streams/readable.js +2 -2
  74. package/dist/query/helpers/streams/readable.js.map +1 -1
  75. package/dist/query/helpers/streams/readable.mjs +1 -1
  76. package/dist/query/helpers/streams/readable.mjs.map +1 -1
  77. package/dist/schema/diff.d.ts.map +1 -1
  78. package/dist/schema/diff.js +3 -3
  79. package/dist/schema/diff.js.map +1 -1
  80. package/dist/schema/diff.mjs +3 -3
  81. package/dist/schema/diff.mjs.map +1 -1
  82. package/dist/schema/index.d.ts.map +1 -1
  83. package/dist/schema/index.js +20 -18
  84. package/dist/schema/index.js.map +1 -1
  85. package/dist/schema/index.mjs +20 -18
  86. package/dist/schema/index.mjs.map +1 -1
  87. package/dist/utils/knex-log.d.ts +19 -0
  88. package/dist/utils/knex-log.d.ts.map +1 -0
  89. package/dist/utils/knex-log.js +51 -0
  90. package/dist/utils/knex-log.js.map +1 -0
  91. package/dist/utils/knex-log.mjs +47 -0
  92. package/dist/utils/knex-log.mjs.map +1 -0
  93. package/dist/utils/throttle.d.ts +26 -0
  94. package/dist/utils/throttle.d.ts.map +1 -0
  95. package/dist/utils/throttle.js +34 -0
  96. package/dist/utils/throttle.js.map +1 -0
  97. package/dist/utils/throttle.mjs +32 -0
  98. package/dist/utils/throttle.mjs.map +1 -0
  99. package/dist/utils/types.d.ts.map +1 -1
  100. package/dist/utils/types.js +9 -9
  101. package/dist/utils/types.js.map +1 -1
  102. package/dist/utils/types.mjs +9 -9
  103. package/dist/utils/types.mjs.map +1 -1
  104. package/package.json +7 -7
@@ -71,24 +71,26 @@ const createSchemaProvider = (db)=>{
71
71
  // TODO: support option to disable auto migration & run a CLI command instead to avoid doing it at startup
72
72
  // TODO: Allow keeping extra indexes / extra tables / extra columns (globally or on a per table basis)
73
73
  async sync () {
74
- if (await db.migrations.shouldRun()) {
75
- debug('Found migrations to run');
76
- await db.migrations.up();
77
- return this.syncSchema();
78
- }
79
- const oldSchema = await this.schemaStorage.read();
80
- if (!oldSchema) {
81
- debug('Schema not persisted yet');
82
- return this.syncSchema();
83
- }
84
- const { hash: oldHash } = oldSchema;
85
- const hash = await this.schemaStorage.hashSchema(this.schema);
86
- if (oldHash !== hash) {
87
- debug('Schema changed');
88
- return this.syncSchema();
89
- }
90
- debug('Schema unchanged');
91
- return 'UNCHANGED';
74
+ return db.runInPhase('schema sync', async ()=>{
75
+ if (await db.migrations.shouldRun()) {
76
+ debug('Found migrations to run');
77
+ await db.migrations.up();
78
+ return this.syncSchema();
79
+ }
80
+ const oldSchema = await this.schemaStorage.read();
81
+ if (!oldSchema) {
82
+ debug('Schema not persisted yet');
83
+ return this.syncSchema();
84
+ }
85
+ const { hash: oldHash } = oldSchema;
86
+ const hash = await this.schemaStorage.hashSchema(this.schema);
87
+ if (oldHash !== hash) {
88
+ debug('Schema changed');
89
+ return this.syncSchema();
90
+ }
91
+ debug('Schema unchanged');
92
+ return 'UNCHANGED';
93
+ });
92
94
  }
93
95
  };
94
96
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/schema/index.ts"],"sourcesContent":["import createDebug from 'debug';\n\nimport createSchemaBuilder from './builder';\nimport createSchemaDiff from './diff';\nimport createSchemaStorage from './storage';\nimport { metadataToSchema } from './schema';\nimport { createRenameHelpers } from './rename-helpers';\n\nimport type { Schema, SchemaDiff } from './types';\nimport type { RenameHelpers } from './rename-helpers';\nimport type { Database } from '..';\n\nexport type * from './types';\nexport type { AttributeRenameHandler, AttributeRenames, RenameHelpers } from './rename-helpers';\n\nconst debug = createDebug('strapi::database');\n\nexport interface SchemaProvider extends RenameHelpers {\n builder: ReturnType<typeof createSchemaBuilder>;\n schemaDiff: ReturnType<typeof createSchemaDiff>;\n schemaStorage: ReturnType<typeof createSchemaStorage>;\n sync(): Promise<SchemaDiff['status']>;\n syncSchema(): Promise<SchemaDiff['status']>;\n reset(): Promise<void>;\n create(): Promise<void>;\n drop(): Promise<void>;\n schema: Schema;\n}\n\ninterface State {\n schema?: Schema;\n}\n\nexport const createSchemaProvider = (db: Database): SchemaProvider => {\n const state: State = {};\n\n return {\n get schema() {\n if (!state.schema) {\n debug('Converting metadata to database schema');\n state.schema = metadataToSchema(db.metadata);\n }\n\n return state.schema;\n },\n builder: createSchemaBuilder(db),\n schemaDiff: createSchemaDiff(db),\n schemaStorage: createSchemaStorage(db),\n\n // Guarded, logged runtime helpers for generated rename migrations\n // (`db.schema.renameColumn(knex, …)` etc.). See rename-helpers.ts.\n ...createRenameHelpers({ db }),\n\n /**\n * Drops the database schema\n */\n async drop() {\n debug('Dropping database schema');\n\n const DBSchema = await db.dialect.schemaInspector.getSchema();\n await this.builder.dropSchema(DBSchema);\n },\n\n /**\n * Creates the database schema\n */\n async create() {\n debug('Created database schema');\n await this.builder.createSchema(this.schema);\n },\n\n /**\n * Resets the database schema\n */\n async reset() {\n debug('Resetting database schema');\n await this.drop();\n await this.create();\n },\n\n async syncSchema(): Promise<SchemaDiff['status']> {\n debug('Synchronizing database schema');\n\n const databaseSchema = await db.dialect.schemaInspector.getSchema();\n const storedSchema = await this.schemaStorage.read();\n\n /*\n 3way diff - DB schema / previous metadataSchema / new metadataSchema\n\n - When something doesn't exist in the previous metadataSchema -> It's not tracked by us and should be ignored\n - If no previous metadataSchema => use new metadataSchema so we start tracking them and ignore everything else\n - Apply this logic to Tables / Columns / Indexes / FKs ...\n - Handle errors (indexes or fks on incompatible stuff ...)\n\n */\n\n const { status, diff } = await this.schemaDiff.diff({\n previousSchema: storedSchema?.schema,\n databaseSchema,\n userSchema: this.schema,\n });\n\n if (status === 'CHANGED') {\n await this.builder.updateSchema(diff);\n }\n\n await this.schemaStorage.add(this.schema);\n\n return status;\n },\n\n // TODO: support options to migrate softly or forcefully\n // TODO: support option to disable auto migration & run a CLI command instead to avoid doing it at startup\n // TODO: Allow keeping extra indexes / extra tables / extra columns (globally or on a per table basis)\n async sync(): Promise<SchemaDiff['status']> {\n if (await db.migrations.shouldRun()) {\n debug('Found migrations to run');\n await db.migrations.up();\n\n return this.syncSchema();\n }\n\n const oldSchema = await this.schemaStorage.read();\n\n if (!oldSchema) {\n debug('Schema not persisted yet');\n return this.syncSchema();\n }\n\n const { hash: oldHash } = oldSchema;\n const hash = await this.schemaStorage.hashSchema(this.schema);\n\n if (oldHash !== hash) {\n debug('Schema changed');\n\n return this.syncSchema();\n }\n\n debug('Schema unchanged');\n\n return 'UNCHANGED';\n },\n };\n};\n"],"names":["debug","createDebug","createSchemaProvider","db","state","schema","metadataToSchema","metadata","builder","createSchemaBuilder","schemaDiff","createSchemaDiff","schemaStorage","createSchemaStorage","createRenameHelpers","drop","DBSchema","dialect","schemaInspector","getSchema","dropSchema","create","createSchema","reset","syncSchema","databaseSchema","storedSchema","read","status","diff","previousSchema","userSchema","updateSchema","add","sync","migrations","shouldRun","up","oldSchema","hash","oldHash","hashSchema"],"mappings":";;;;;;;AAeA,MAAMA,QAAQC,WAAAA,CAAY,kBAAA,CAAA;AAkBnB,MAAMC,uBAAuB,CAACC,EAAAA,GAAAA;AACnC,IAAA,MAAMC,QAAe,EAAC;IAEtB,OAAO;AACL,QAAA,IAAIC,MAAAA,CAAAA,GAAS;YACX,IAAI,CAACD,KAAAA,CAAMC,MAAM,EAAE;gBACjBL,KAAAA,CAAM,wCAAA,CAAA;AACNI,gBAAAA,KAAAA,CAAMC,MAAM,GAAGC,gBAAAA,CAAiBH,EAAAA,CAAGI,QAAQ,CAAA;AAC7C,YAAA;AAEA,YAAA,OAAOH,MAAMC,MAAM;AACrB,QAAA,CAAA;AACAG,QAAAA,OAAAA,EAASC,mBAAAA,CAAoBN,EAAAA,CAAAA;AAC7BO,QAAAA,UAAAA,EAAYC,gBAAAA,CAAiBR,EAAAA,CAAAA;AAC7BS,QAAAA,aAAAA,EAAeC,mBAAAA,CAAoBV,EAAAA,CAAAA;;;AAInC,QAAA,GAAGW,mBAAAA,CAAoB;AAAEX,YAAAA;SAAG,CAAE;AAE9B;;AAEC,QACD,MAAMY,IAAAA,CAAAA,GAAAA;YACJf,KAAAA,CAAM,0BAAA,CAAA;AAEN,YAAA,MAAMg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,CAAAA,GAAAA;AACJ,YAAA,IAAI,MAAM/B,EAAAA,CAAGgC,UAAU,CAACC,SAAS,EAAA,EAAI;gBACnCpC,KAAAA,CAAM,yBAAA,CAAA;gBACN,MAAMG,EAAAA,CAAGgC,UAAU,CAACE,EAAE,EAAA;gBAEtB,OAAO,IAAI,CAACb,UAAU,EAAA;AACxB,YAAA;AAEA,YAAA,MAAMc,YAAY,MAAM,IAAI,CAAC1B,aAAa,CAACe,IAAI,EAAA;AAE/C,YAAA,IAAI,CAACW,SAAAA,EAAW;gBACdtC,KAAAA,CAAM,0BAAA,CAAA;gBACN,OAAO,IAAI,CAACwB,UAAU,EAAA;AACxB,YAAA;AAEA,YAAA,MAAM,EAAEe,IAAAA,EAAMC,OAAO,EAAE,GAAGF,SAAAA;YAC1B,MAAMC,IAAAA,GAAO,MAAM,IAAI,CAAC3B,aAAa,CAAC6B,UAAU,CAAC,IAAI,CAACpC,MAAM,CAAA;AAE5D,YAAA,IAAImC,YAAYD,IAAAA,EAAM;gBACpBvC,KAAAA,CAAM,gBAAA,CAAA;gBAEN,OAAO,IAAI,CAACwB,UAAU,EAAA;AACxB,YAAA;YAEAxB,KAAAA,CAAM,kBAAA,CAAA;YAEN,OAAO,WAAA;AACT,QAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/schema/index.ts"],"sourcesContent":["import createDebug from 'debug';\n\nimport createSchemaBuilder from './builder';\nimport createSchemaDiff from './diff';\nimport createSchemaStorage from './storage';\nimport { metadataToSchema } from './schema';\nimport { createRenameHelpers } from './rename-helpers';\n\nimport type { Schema, SchemaDiff } from './types';\nimport type { RenameHelpers } from './rename-helpers';\nimport type { Database } from '..';\n\nexport type * from './types';\nexport type { AttributeRenameHandler, AttributeRenames, RenameHelpers } from './rename-helpers';\n\nconst debug = createDebug('strapi::database');\n\nexport interface SchemaProvider extends RenameHelpers {\n builder: ReturnType<typeof createSchemaBuilder>;\n schemaDiff: ReturnType<typeof createSchemaDiff>;\n schemaStorage: ReturnType<typeof createSchemaStorage>;\n sync(): Promise<SchemaDiff['status']>;\n syncSchema(): Promise<SchemaDiff['status']>;\n reset(): Promise<void>;\n create(): Promise<void>;\n drop(): Promise<void>;\n schema: Schema;\n}\n\ninterface State {\n schema?: Schema;\n}\n\nexport const createSchemaProvider = (db: Database): SchemaProvider => {\n const state: State = {};\n\n return {\n get schema() {\n if (!state.schema) {\n debug('Converting metadata to database schema');\n state.schema = metadataToSchema(db.metadata);\n }\n\n return state.schema;\n },\n builder: createSchemaBuilder(db),\n schemaDiff: createSchemaDiff(db),\n schemaStorage: createSchemaStorage(db),\n\n // Guarded, logged runtime helpers for generated rename migrations\n // (`db.schema.renameColumn(knex, …)` etc.). See rename-helpers.ts.\n ...createRenameHelpers({ db }),\n\n /**\n * Drops the database schema\n */\n async drop() {\n debug('Dropping database schema');\n\n const DBSchema = await db.dialect.schemaInspector.getSchema();\n await this.builder.dropSchema(DBSchema);\n },\n\n /**\n * Creates the database schema\n */\n async create() {\n debug('Created database schema');\n await this.builder.createSchema(this.schema);\n },\n\n /**\n * Resets the database schema\n */\n async reset() {\n debug('Resetting database schema');\n await this.drop();\n await this.create();\n },\n\n async syncSchema(): Promise<SchemaDiff['status']> {\n debug('Synchronizing database schema');\n\n const databaseSchema = await db.dialect.schemaInspector.getSchema();\n const storedSchema = await this.schemaStorage.read();\n\n /*\n 3way diff - DB schema / previous metadataSchema / new metadataSchema\n\n - When something doesn't exist in the previous metadataSchema -> It's not tracked by us and should be ignored\n - If no previous metadataSchema => use new metadataSchema so we start tracking them and ignore everything else\n - Apply this logic to Tables / Columns / Indexes / FKs ...\n - Handle errors (indexes or fks on incompatible stuff ...)\n\n */\n\n const { status, diff } = await this.schemaDiff.diff({\n previousSchema: storedSchema?.schema,\n databaseSchema,\n userSchema: this.schema,\n });\n\n if (status === 'CHANGED') {\n await this.builder.updateSchema(diff);\n }\n\n await this.schemaStorage.add(this.schema);\n\n return status;\n },\n\n // TODO: support options to migrate softly or forcefully\n // TODO: support option to disable auto migration & run a CLI command instead to avoid doing it at startup\n // TODO: Allow keeping extra indexes / extra tables / extra columns (globally or on a per table basis)\n async sync(): Promise<SchemaDiff['status']> {\n return db.runInPhase('schema sync', async () => {\n if (await db.migrations.shouldRun()) {\n debug('Found migrations to run');\n await db.migrations.up();\n\n return this.syncSchema();\n }\n\n const oldSchema = await this.schemaStorage.read();\n\n if (!oldSchema) {\n debug('Schema not persisted yet');\n return this.syncSchema();\n }\n\n const { hash: oldHash } = oldSchema;\n const hash = await this.schemaStorage.hashSchema(this.schema);\n\n if (oldHash !== hash) {\n debug('Schema changed');\n\n return this.syncSchema();\n }\n\n debug('Schema unchanged');\n\n return 'UNCHANGED';\n });\n },\n };\n};\n"],"names":["debug","createDebug","createSchemaProvider","db","state","schema","metadataToSchema","metadata","builder","createSchemaBuilder","schemaDiff","createSchemaDiff","schemaStorage","createSchemaStorage","createRenameHelpers","drop","DBSchema","dialect","schemaInspector","getSchema","dropSchema","create","createSchema","reset","syncSchema","databaseSchema","storedSchema","read","status","diff","previousSchema","userSchema","updateSchema","add","sync","runInPhase","migrations","shouldRun","up","oldSchema","hash","oldHash","hashSchema"],"mappings":";;;;;;;AAeA,MAAMA,QAAQC,WAAAA,CAAY,kBAAA,CAAA;AAkBnB,MAAMC,uBAAuB,CAACC,EAAAA,GAAAA;AACnC,IAAA,MAAMC,QAAe,EAAC;IAEtB,OAAO;AACL,QAAA,IAAIC,MAAAA,CAAAA,GAAS;YACX,IAAI,CAACD,KAAAA,CAAMC,MAAM,EAAE;gBACjBL,KAAAA,CAAM,wCAAA,CAAA;AACNI,gBAAAA,KAAAA,CAAMC,MAAM,GAAGC,gBAAAA,CAAiBH,EAAAA,CAAGI,QAAQ,CAAA;AAC7C,YAAA;AAEA,YAAA,OAAOH,MAAMC,MAAM;AACrB,QAAA,CAAA;AACAG,QAAAA,OAAAA,EAASC,mBAAAA,CAAoBN,EAAAA,CAAAA;AAC7BO,QAAAA,UAAAA,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ed connection acquire. */
3
+ export declare const KNEX_ACQUIRE_ERROR_PREFIX = "Acquire connection error:";
4
+ interface WarnLogger {
5
+ warn(message: string): void;
6
+ }
7
+ export interface KnexWarnOptions {
8
+ intervalMs?: number;
9
+ now?: () => number;
10
+ }
11
+ /**
12
+ * During pool exhaustion knex warns once per waiting query. Keep the first acquire warning and at
13
+ * most one per interval after it; pass every other knex warning through.
14
+ */
15
+ export declare const createKnexWarn: (logger: WarnLogger, { intervalMs, now }?: KnexWarnOptions) => (message: unknown) => void;
16
+ /** Route knex's warnings through the Strapi logger unless the project configured its own. */
17
+ export declare const withStrapiKnexLog: (config: Knex.Config, logger: WarnLogger, options?: KnexWarnOptions) => Knex.Config;
18
+ export {};
19
+ //# sourceMappingURL=knex-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knex-log.d.ts","sourceRoot":"","sources":["../../src/utils/knex-log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAIjC,4EAA4E;AAC5E,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAIrE,UAAU,UAAU;IAClB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,UAAU,EAClB,sBAAgD,eAAoB,MAI5D,SAAS,OAAO,SAwBzB,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,IAAI,CAAC,MAAM,EACnB,QAAQ,UAAU,EAClB,UAAU,eAAe,KACxB,IAAI,CAAC,MAQP,CAAC"}
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var throttle = require('./throttle.js');
4
+
5
+ /** knex 3.3 logs this, with a stack, on every failed connection acquire. */ const KNEX_ACQUIRE_ERROR_PREFIX = 'Acquire connection error:';
6
+ const KNEX_WARNING_INTERVAL_MS = 30000;
7
+ /**
8
+ * During pool exhaustion knex warns once per waiting query. Keep the first acquire warning and at
9
+ * most one per interval after it; pass every other knex warning through.
10
+ */ const createKnexWarn = (logger, { intervalMs = KNEX_WARNING_INTERVAL_MS, now } = {})=>{
11
+ const acquireErrors = throttle.createThrottle({
12
+ intervalMs,
13
+ now
14
+ });
15
+ return (message)=>{
16
+ try {
17
+ const text = typeof message === 'string' ? message : String(message);
18
+ if (!text.startsWith(KNEX_ACQUIRE_ERROR_PREFIX)) {
19
+ logger.warn(`[database] knex: ${text}`);
20
+ return;
21
+ }
22
+ const { emit, suppressed } = acquireErrors.take();
23
+ if (!emit) {
24
+ return;
25
+ }
26
+ const held = suppressed > 0 ? `\n - acquire connection errors not logged since the previous one: ${suppressed}` : '';
27
+ logger.warn(`[database] knex: ${text}${held}`);
28
+ } catch {
29
+ // knex calls this from inside a catch block, right before it throws the error the caller
30
+ // needs to see. A failing logger (custom logger, broken transport) must not replace that error.
31
+ }
32
+ };
33
+ };
34
+ /** Route knex's warnings through the Strapi logger unless the project configured its own. */ const withStrapiKnexLog = (config, logger, options)=>{
35
+ const projectLog = config.log ?? {};
36
+ if (typeof projectLog.warn === 'function') {
37
+ return config;
38
+ }
39
+ return {
40
+ ...config,
41
+ log: {
42
+ ...projectLog,
43
+ warn: createKnexWarn(logger, options)
44
+ }
45
+ };
46
+ };
47
+
48
+ exports.KNEX_ACQUIRE_ERROR_PREFIX = KNEX_ACQUIRE_ERROR_PREFIX;
49
+ exports.createKnexWarn = createKnexWarn;
50
+ exports.withStrapiKnexLog = withStrapiKnexLog;
51
+ //# sourceMappingURL=knex-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knex-log.js","sources":["../../src/utils/knex-log.ts"],"sourcesContent":["import type { Knex } from 'knex';\n\nimport { createThrottle } from './throttle';\n\n/** knex 3.3 logs this, with a stack, on every failed connection acquire. */\nexport const KNEX_ACQUIRE_ERROR_PREFIX = 'Acquire connection error:';\n\nconst KNEX_WARNING_INTERVAL_MS = 30_000;\n\ninterface WarnLogger {\n warn(message: string): void;\n}\n\nexport interface KnexWarnOptions {\n intervalMs?: number;\n now?: () => number;\n}\n\n/**\n * During pool exhaustion knex warns once per waiting query. Keep the first acquire warning and at\n * most one per interval after it; pass every other knex warning through.\n */\nexport const createKnexWarn = (\n logger: WarnLogger,\n { intervalMs = KNEX_WARNING_INTERVAL_MS, now }: KnexWarnOptions = {}\n) => {\n const acquireErrors = createThrottle({ intervalMs, now });\n\n return (message: unknown) => {\n try {\n const text = typeof message === 'string' ? message : String(message);\n\n if (!text.startsWith(KNEX_ACQUIRE_ERROR_PREFIX)) {\n logger.warn(`[database] knex: ${text}`);\n return;\n }\n\n const { emit, suppressed } = acquireErrors.take();\n if (!emit) {\n return;\n }\n\n const held =\n suppressed > 0\n ? `\\n - acquire connection errors not logged since the previous one: ${suppressed}`\n : '';\n logger.warn(`[database] knex: ${text}${held}`);\n } catch {\n // knex calls this from inside a catch block, right before it throws the error the caller\n // needs to see. A failing logger (custom logger, broken transport) must not replace that error.\n }\n };\n};\n\n/** Route knex's warnings through the Strapi logger unless the project configured its own. */\nexport const withStrapiKnexLog = (\n config: Knex.Config,\n logger: WarnLogger,\n options?: KnexWarnOptions\n): Knex.Config => {\n const projectLog = config.log ?? {};\n\n if (typeof projectLog.warn === 'function') {\n return config;\n }\n\n return { ...config, log: { ...projectLog, warn: createKnexWarn(logger, options) } };\n};\n"],"names":["KNEX_ACQUIRE_ERROR_PREFIX","KNEX_WARNING_INTERVAL_MS","createKnexWarn","logger","intervalMs","now","acquireErrors","createThrottle","message","text","String","startsWith","warn","emit","suppressed","take","held","withStrapiKnexLog","config","options","projectLog","log"],"mappings":";;;;AAIA,6EACO,MAAMA,yBAAAA,GAA4B;AAEzC,MAAMC,wBAAAA,GAA2B,KAAA;AAWjC;;;AAGC,IACM,MAAMC,cAAAA,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AA,GAAGD,UAAU;AAAER,YAAAA,IAAAA,EAAMV,eAAeC,MAAAA,EAAQgB,OAAAA;AAAS;AAAE,KAAA;AACpF;;;;;;"}
@@ -0,0 +1,47 @@
1
+ import { createThrottle } from './throttle.mjs';
2
+
3
+ /** knex 3.3 logs this, with a stack, on every failed connection acquire. */ const KNEX_ACQUIRE_ERROR_PREFIX = 'Acquire connection error:';
4
+ const KNEX_WARNING_INTERVAL_MS = 30000;
5
+ /**
6
+ * During pool exhaustion knex warns once per waiting query. Keep the first acquire warning and at
7
+ * most one per interval after it; pass every other knex warning through.
8
+ */ const createKnexWarn = (logger, { intervalMs = KNEX_WARNING_INTERVAL_MS, now } = {})=>{
9
+ const acquireErrors = createThrottle({
10
+ intervalMs,
11
+ now
12
+ });
13
+ return (message)=>{
14
+ try {
15
+ const text = typeof message === 'string' ? message : String(message);
16
+ if (!text.startsWith(KNEX_ACQUIRE_ERROR_PREFIX)) {
17
+ logger.warn(`[database] knex: ${text}`);
18
+ return;
19
+ }
20
+ const { emit, suppressed } = acquireErrors.take();
21
+ if (!emit) {
22
+ return;
23
+ }
24
+ const held = suppressed > 0 ? `\n - acquire connection errors not logged since the previous one: ${suppressed}` : '';
25
+ logger.warn(`[database] knex: ${text}${held}`);
26
+ } catch {
27
+ // knex calls this from inside a catch block, right before it throws the error the caller
28
+ // needs to see. A failing logger (custom logger, broken transport) must not replace that error.
29
+ }
30
+ };
31
+ };
32
+ /** Route knex's warnings through the Strapi logger unless the project configured its own. */ const withStrapiKnexLog = (config, logger, options)=>{
33
+ const projectLog = config.log ?? {};
34
+ if (typeof projectLog.warn === 'function') {
35
+ return config;
36
+ }
37
+ return {
38
+ ...config,
39
+ log: {
40
+ ...projectLog,
41
+ warn: createKnexWarn(logger, options)
42
+ }
43
+ };
44
+ };
45
+
46
+ export { KNEX_ACQUIRE_ERROR_PREFIX, createKnexWarn, withStrapiKnexLog };
47
+ //# sourceMappingURL=knex-log.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knex-log.mjs","sources":["../../src/utils/knex-log.ts"],"sourcesContent":["import type { Knex } from 'knex';\n\nimport { createThrottle } from './throttle';\n\n/** knex 3.3 logs this, with a stack, on every failed connection acquire. */\nexport const KNEX_ACQUIRE_ERROR_PREFIX = 'Acquire connection error:';\n\nconst KNEX_WARNING_INTERVAL_MS = 30_000;\n\ninterface WarnLogger {\n warn(message: string): void;\n}\n\nexport interface KnexWarnOptions {\n intervalMs?: number;\n now?: () => number;\n}\n\n/**\n * During pool exhaustion knex warns once per waiting query. Keep the first acquire warning and at\n * most one per interval after it; pass every other knex warning through.\n */\nexport const createKnexWarn = (\n logger: WarnLogger,\n { intervalMs = KNEX_WARNING_INTERVAL_MS, now }: KnexWarnOptions = {}\n) => {\n const acquireErrors = createThrottle({ intervalMs, now });\n\n return (message: unknown) => {\n try {\n const text = typeof message === 'string' ? message : String(message);\n\n if (!text.startsWith(KNEX_ACQUIRE_ERROR_PREFIX)) {\n logger.warn(`[database] knex: ${text}`);\n return;\n }\n\n const { emit, suppressed } = acquireErrors.take();\n if (!emit) {\n return;\n }\n\n const held =\n suppressed > 0\n ? `\\n - acquire connection errors not logged since the previous one: ${suppressed}`\n : '';\n logger.warn(`[database] knex: ${text}${held}`);\n } catch {\n // knex calls this from inside a catch block, right before it throws the error the caller\n // needs to see. A failing logger (custom logger, broken transport) must not replace that error.\n }\n };\n};\n\n/** Route knex's warnings through the Strapi logger unless the project configured its own. */\nexport const withStrapiKnexLog = (\n config: Knex.Config,\n logger: WarnLogger,\n options?: KnexWarnOptions\n): Knex.Config => {\n const projectLog = config.log ?? {};\n\n if (typeof projectLog.warn === 'function') {\n return config;\n }\n\n return { ...config, log: { ...projectLog, warn: createKnexWarn(logger, options) } };\n};\n"],"names":["KNEX_ACQUIRE_ERROR_PREFIX","KNEX_WARNING_INTERVAL_MS","createKnexWarn","logger","intervalMs","now","acquireErrors","createThrottle","message","text","String","startsWith","warn","emit","suppressed","take","held","withStrapiKnexLog","config","options","proj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IAAI,KAAK,UAAA,EAAY;QACzC,OAAOM,MAAAA;AACT,IAAA;IAEA,OAAO;AAAE,QAAA,GAAGA,MAAM;QAAEG,GAAAA,EAAK;AAAE,YAAA,GAAGD,UAAU;AAAER,YAAAA,IAAAA,EAAMV,eAAeC,MAAAA,EAAQgB,OAAAA;AAAS;AAAE,KAAA;AACpF;;;;"}
@@ -0,0 +1,26 @@
1
+ export interface ThrottleOptions {
2
+ /** Minimum time between two emissions. */
3
+ intervalMs: number;
4
+ /**
5
+ * Clock in milliseconds, injectable for tests. Defaults to performance.now(), which is monotonic:
6
+ * a wall clock stepping backwards (NTP, VM resume) would hold the throttle shut for the size of
7
+ * the step plus the interval.
8
+ */
9
+ now?: () => number;
10
+ }
11
+ export interface ThrottleDecision {
12
+ /** True when the caller should log now. */
13
+ emit: boolean;
14
+ /** Calls not emitted since the previous emission (reported with the next one). */
15
+ suppressed: number;
16
+ }
17
+ export interface Throttle {
18
+ take(): ThrottleDecision;
19
+ }
20
+ /**
21
+ * Lets the first call through, then at most one per interval, and counts what it held back.
22
+ * Sibling of createHeartbeatLogger (migrations/heartbeat.ts), which only emits once a full interval
23
+ * has passed and so would drop the first warning of an incident.
24
+ */
25
+ export declare const createThrottle: ({ intervalMs, now, }: ThrottleOptions) => Throttle;
26
+ //# sourceMappingURL=throttle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/utils/throttle.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,IAAI,EAAE,OAAO,CAAC;IACd,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,IAAI,gBAAgB,CAAC;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,sBAG5B,eAAe,KAAG,QAmBpB,CAAC"}
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var node_perf_hooks = require('node:perf_hooks');
4
+
5
+ /**
6
+ * Lets the first call through, then at most one per interval, and counts what it held back.
7
+ * Sibling of createHeartbeatLogger (migrations/heartbeat.ts), which only emits once a full interval
8
+ * has passed and so would drop the first warning of an incident.
9
+ */ const createThrottle = ({ intervalMs, now = ()=>node_perf_hooks.performance.now() })=>{
10
+ let lastEmittedAt;
11
+ let suppressed = 0;
12
+ return {
13
+ take () {
14
+ const current = now();
15
+ if (lastEmittedAt !== undefined && current - lastEmittedAt < intervalMs) {
16
+ suppressed += 1;
17
+ return {
18
+ emit: false,
19
+ suppressed
20
+ };
21
+ }
22
+ const held = suppressed;
23
+ suppressed = 0;
24
+ lastEmittedAt = current;
25
+ return {
26
+ emit: true,
27
+ suppressed: held
28
+ };
29
+ }
30
+ };
31
+ };
32
+
33
+ exports.createThrottle = createThrottle;
34
+ //# sourceMappingURL=throttle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"throttle.js","sources":["../../src/utils/throttle.ts"],"sourcesContent":["import { performance } from 'node:perf_hooks';\n\nexport interface ThrottleOptions {\n /** Minimum time between two emissions. */\n intervalMs: number;\n /**\n * Clock in milliseconds, injectable for tests. Defaults to performance.now(), which is monotonic:\n * a wall clock stepping backwards (NTP, VM resume) would hold the throttle shut for the size of\n * the step plus the interval.\n */\n now?: () => number;\n}\n\nexport interface ThrottleDecision {\n /** True when the caller should log now. */\n emit: boolean;\n /** Calls not emitted since the previous emission (reported with the next one). */\n suppressed: number;\n}\n\nexport interface Throttle {\n take(): ThrottleDecision;\n}\n\n/**\n * Lets the first call through, then at most one per interval, and counts what it held back.\n * Sibling of createHeartbeatLogger (migrations/heartbeat.ts), which only emits once a full interval\n * has passed and so would drop the first warning of an incident.\n */\nexport const createThrottle = ({\n intervalMs,\n now = () => performance.now(),\n}: ThrottleOptions): Throttle => {\n let lastEmittedAt: number | undefined;\n let suppressed = 0;\n\n return {\n take() {\n const current = now();\n\n if (lastEmittedAt !== undefined && current - lastEmittedAt < intervalMs) {\n suppressed += 1;\n return { emit: false, suppressed };\n }\n\n const held = suppressed;\n suppressed = 0;\n lastEmittedAt = current;\n return { emit: true, suppressed: held };\n },\n };\n};\n"],"names":["createThrottle","intervalMs","now","performance","lastEmittedAt","suppressed","take","current","undefined","emit","held"],"mappings":";;;;AAwBA;;;;AAIC,IACM,MAAMA,cAAAA,GAAiB,CAAC,EAC7BC,UAAU,EACVC,GAAAA,GAAM,IAAMC,2BAAAA,CAAYD,GAAG,EAAE,EACb,GAAA;IAChB,IAAIE,aAAAA;AACJ,IAAA,IAAIC,UAAAA,GAAa,CAAA;IAEjB,OAAO;AACLC,QAAAA,IAAAA,CAAAA,GAAAA;AACE,YAAA,MAAMC,OAAAA,GAAUL,GAAAA,EAAAA;AAEhB,YAAA,IAAIE,aAAAA,KAAkBI,SAAAA,IAAaD,OAAAA,GAAUH,aAAAA,GAAgBH,UAAAA,EAAY;gBACvEI,UAAAA,IAAc,CAAA;gBACd,OAAO;oBAAEI,IAAAA,EAAM,KAAA;AAAOJ,oBAAAA;AAAW,iBAAA;AACnC,YAAA;AAEA,YAAA,MAAMK,IAAAA,GAAOL,UAAAA;YACbA,UAAAA,GAAa,CAAA;YACbD,aAAAA,GAAgBG,OAAAA;YAChB,OAAO;gBAAEE,IAAAA,EAAM,IAAA;gBAAMJ,UAAAA,EAAYK;AAAK,aAAA;AACxC,QAAA;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,32 @@
1
+ import { performance } from 'node:perf_hooks';
2
+
3
+ /**
4
+ * Lets the first call through, then at most one per interval, and counts what it held back.
5
+ * Sibling of createHeartbeatLogger (migrations/heartbeat.ts), which only emits once a full interval
6
+ * has passed and so would drop the first warning of an incident.
7
+ */ const createThrottle = ({ intervalMs, now = ()=>performance.now() })=>{
8
+ let lastEmittedAt;
9
+ let suppressed = 0;
10
+ return {
11
+ take () {
12
+ const current = now();
13
+ if (lastEmittedAt !== undefined && current - lastEmittedAt < intervalMs) {
14
+ suppressed += 1;
15
+ return {
16
+ emit: false,
17
+ suppressed
18
+ };
19
+ }
20
+ const held = suppressed;
21
+ suppressed = 0;
22
+ lastEmittedAt = current;
23
+ return {
24
+ emit: true,
25
+ suppressed: held
26
+ };
27
+ }
28
+ };
29
+ };
30
+
31
+ export { createThrottle };
32
+ //# sourceMappingURL=throttle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"throttle.mjs","sources":["../../src/utils/throttle.ts"],"sourcesContent":["import { performance } from 'node:perf_hooks';\n\nexport interface ThrottleOptions {\n /** Minimum time between two emissions. */\n intervalMs: number;\n /**\n * Clock in milliseconds, injectable for tests. Defaults to performance.now(), which is monotonic:\n * a wall clock stepping backwards (NTP, VM resume) would hold the throttle shut for the size of\n * the step plus the interval.\n */\n now?: () => number;\n}\n\nexport interface ThrottleDecision {\n /** True when the caller should log now. */\n emit: boolean;\n /** Calls not emitted since the previous emission (reported with the next one). */\n suppressed: number;\n}\n\nexport interface Throttle {\n take(): ThrottleDecision;\n}\n\n/**\n * Lets the first call through, then at most one per interval, and counts what it held back.\n * Sibling of createHeartbeatLogger (migrations/heartbeat.ts), which only emits once a full interval\n * has passed and so would drop the first warning of an incident.\n */\nexport const createThrottle = ({\n intervalMs,\n now = () => performance.now(),\n}: ThrottleOptions): Throttle => {\n let lastEmittedAt: number | undefined;\n let suppressed = 0;\n\n return {\n take() {\n const current = now();\n\n if (lastEmittedAt !== undefined && current - lastEmittedAt < intervalMs) {\n suppressed += 1;\n return { emit: false, suppressed };\n }\n\n const held = suppressed;\n suppressed = 0;\n lastEmittedAt = current;\n return { emit: true, suppressed: held };\n },\n };\n};\n"],"names":["createThrottle","intervalMs","now","performance","lastEmittedAt","suppressed","take","current","undefined","emit","held"],"mappings":";;AAwBA;;;;AAIC,IACM,MAAMA,cAAA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ourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AA2BhF,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,YAA2B,CAAC;AACjE,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,YAA2B,CAAC;AACjE,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,YAA2B,CAAC;AACjE,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,uBAAwB,CAAC;AAChE,eAAO,MAAM,iBAAiB,GAAI,WAAW,SAAS,KAAG,SAAS,IAAI,eAC5C,CAAC;AAC3B,eAAO,MAAM,qBAAqB,GAAI,WAAW,SAAS,KAAG,SAAS,IAAI,mBAC9C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const SCALAR_TYPES = [
3
+ const SCALAR_TYPES = new Set([
4
4
  'increments',
5
5
  'password',
6
6
  'email',
@@ -20,24 +20,24 @@ const SCALAR_TYPES = [
20
20
  'timestamp',
21
21
  'boolean',
22
22
  'blocks'
23
- ];
24
- const STRING_TYPES = [
23
+ ]);
24
+ const STRING_TYPES = new Set([
25
25
  'string',
26
26
  'text',
27
27
  'uid',
28
28
  'email',
29
29
  'enumeration',
30
30
  'richtext'
31
- ];
32
- const NUMBER_TYPES = [
31
+ ]);
32
+ const NUMBER_TYPES = new Set([
33
33
  'biginteger',
34
34
  'integer',
35
35
  'decimal',
36
36
  'float'
37
- ];
38
- const isString = (type)=>STRING_TYPES.includes(type);
39
- const isNumber = (type)=>NUMBER_TYPES.includes(type);
40
- const isScalar = (type)=>SCALAR_TYPES.includes(type);
37
+ ]);
38
+ const isString = (type)=>STRING_TYPES.has(type);
39
+ const isNumber = (type)=>NUMBER_TYPES.has(type);
40
+ const isScalar = (type)=>SCALAR_TYPES.has(type);
41
41
  const isRelation = (type)=>type === 'relation';
42
42
  const isScalarAttribute = (attribute)=>isScalar(attribute.type);
43
43
  const isRelationalAttribute = (attribute)=>isRelation(attribute.type);
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../src/utils/types.ts"],"sourcesContent":["import type { Attribute, ScalarAttribute, RelationalAttribute } from '../types';\n\nconst SCALAR_TYPES = [\n 'increments',\n 'password',\n 'email',\n 'string',\n 'uid',\n 'richtext',\n 'text',\n 'json',\n 'enumeration',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n 'blocks',\n];\n\nconst STRING_TYPES = ['string', 'text', 'uid', 'email', 'enumeration', 'richtext'];\nconst NUMBER_TYPES = ['biginteger', 'integer', 'decimal', 'float'];\n\nexport const isString = (type: string) => STRING_TYPES.includes(type);\nexport const isNumber = (type: string) => NUMBER_TYPES.includes(type);\nexport const isScalar = (type: string) => SCALAR_TYPES.includes(type);\nexport const isRelation = (type: string) => type === 'relation';\nexport const isScalarAttribute = (attribute: Attribute): attribute is ScalarAttribute =>\n isScalar(attribute.type);\nexport const isRelationalAttribute = (attribute: Attribute): attribute is RelationalAttribute =>\n isRelation(attribute.type);\n"],"names":["SCALAR_TYPES","STRING_TYPES","NUMBER_TYPES","isString","type","includes","isNumber","isScalar","isRelation","isScalarAttribute","attribute","isRelationalAttribute"],"mappings":";;AAEA,MAAMA,YAAAA,GAAe;AACnB,IAAA,YAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,SAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,YAAAA,GAAe;AAAC,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,KAAA;AAAO,IAAA,OAAA;AAAS,IAAA,aAAA;AAAe,IAAA;AAAW,CAAA;AAClF,MAAMC,YAAAA,GAAe;AAAC,IAAA,YAAA;AAAc,IAAA,SAAA;AAAW,IAAA,SAAA;AAAW,IAAA;AAAQ,CAAA;MAErDC,QAAAA,GAAW,CAACC,OAAiBH,YAAAA,CAAaI,QAAQ,CAACD,IAAAA;MACnDE,QAAAA,GAAW,CAACF,OAAiBF,YAAAA,CAAaG,QAAQ,CAACD,IAAAA;MACnDG,QAAAA,GAAW,CAACH,OAAiBJ,YAAAA,CAAaK,QAAQ,CAACD,IAAAA;AACzD,MAAMI,UAAAA,GAAa,CAACJ,IAAAA,GAAiBA,SAAS;MACxCK,iBAAAA,GAAoB,CAACC,YAChCH,QAAAA,CAASG,SAAAA,CAAUN,IAAI;MACZO,qBAAAA,GAAwB,CAACD,YACpCF,UAAAA,CAAWE,SAAAA,CAAUN,IAAI;;;;;;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../src/utils/types.ts"],"sourcesContent":["import type { Attribute, ScalarAttribute, RelationalAttribute } from '../types';\n\nconst SCALAR_TYPES = new Set([\n 'increments',\n 'password',\n 'email',\n 'string',\n 'uid',\n 'richtext',\n 'text',\n 'json',\n 'enumeration',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n 'blocks',\n]);\n\nconst STRING_TYPES = new Set(['string', 'text', 'uid', 'email', 'enumeration', 'richtext']);\nconst NUMBER_TYPES = new Set(['biginteger', 'integer', 'decimal', 'float']);\n\nexport const isString = (type: string) => STRING_TYPES.has(type);\nexport const isNumber = (type: string) => NUMBER_TYPES.has(type);\nexport const isScalar = (type: string) => SCALAR_TYPES.has(type);\nexport const isRelation = (type: string) => type === 'relation';\nexport const isScalarAttribute = (attribute: Attribute): attribute is ScalarAttribute =>\n isScalar(attribute.type);\nexport const isRelationalAttribute = (attribute: Attribute): attribute is RelationalAttribute =>\n isRelation(attribute.type);\n"],"names":["SCALAR_TYPES","Set","STRING_TYPES","NUMBER_TYPES","isString","type","has","isNumber","isScalar","isRelation","isScalarAttribute","attribute","isRelationalAttribute"],"mappings":";;AAEA,MAAMA,YAAAA,GAAe,IAAIC,GAAAA,CAAI;AAC3B,IAAA,YAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,SAAA;AACA,IAAA;AACD,CAAA,CAAA;AAED,MAAMC,YAAAA,GAAe,IAAID,GAAAA,CAAI;AAAC,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,KAAA;AAAO,IAAA,OAAA;AAAS,IAAA,aAAA;AAAe,IAAA;AAAW,CAAA,CAAA;AAC1F,MAAME,YAAAA,GAAe,IAAIF,GAAAA,CAAI;AAAC,IAAA,YAAA;AAAc,IAAA,SAAA;AAAW,IAAA,SAAA;AAAW,IAAA;AAAQ,CAAA,CAAA;MAE7DG,QAAAA,GAAW,CAACC,OAAiBH,YAAAA,CAAaI,GAAG,CAACD,IAAAA;MAC9CE,QAAAA,GAAW,CAACF,OAAiBF,YAAAA,CAAaG,GAAG,CAACD,IAAAA;MAC9CG,QAAAA,GAAW,CAACH,OAAiBL,YAAAA,CAAaM,GAAG,CAACD,IAAAA;AACpD,MAAMI,UAAAA,GAAa,CAACJ,IAAAA,GAAiBA,SAAS;MACxCK,iBAAAA,GAAoB,CAACC,YAChCH,QAAAA,CAASG,SAAAA,CAAUN,IAAI;MACZO,qBAAAA,GAAwB,CAACD,YACpCF,UAAAA,CAAWE,SAAAA,CAAUN,IAAI;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- const SCALAR_TYPES = [
1
+ const SCALAR_TYPES = new Set([
2
2
  'increments',
3
3
  'password',
4
4
  'email',
@@ -18,24 +18,24 @@ const SCALAR_TYPES = [
18
18
  'timestamp',
19
19
  'boolean',
20
20
  'blocks'
21
- ];
22
- const STRING_TYPES = [
21
+ ]);
22
+ const STRING_TYPES = new Set([
23
23
  'string',
24
24
  'text',
25
25
  'uid',
26
26
  'email',
27
27
  'enumeration',
28
28
  'richtext'
29
- ];
30
- const NUMBER_TYPES = [
29
+ ]);
30
+ const NUMBER_TYPES = new Set([
31
31
  'biginteger',
32
32
  'integer',
33
33
  'decimal',
34
34
  'float'
35
- ];
36
- const isString = (type)=>STRING_TYPES.includes(type);
37
- const isNumber = (type)=>NUMBER_TYPES.includes(type);
38
- const isScalar = (type)=>SCALAR_TYPES.includes(type);
35
+ ]);
36
+ const isString = (type)=>STRING_TYPES.has(type);
37
+ const isNumber = (type)=>NUMBER_TYPES.has(type);
38
+ const isScalar = (type)=>SCALAR_TYPES.has(type);
39
39
  const isRelation = (type)=>type === 'relation';
40
40
  const isScalarAttribute = (attribute)=>isScalar(attribute.type);
41
41
  const isRelationalAttribute = (attribute)=>isRelation(attribute.type);
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sources":["../../src/utils/types.ts"],"sourcesContent":["import type { Attribute, ScalarAttribute, RelationalAttribute } from '../types';\n\nconst SCALAR_TYPES = [\n 'increments',\n 'password',\n 'email',\n 'string',\n 'uid',\n 'richtext',\n 'text',\n 'json',\n 'enumeration',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n 'blocks',\n];\n\nconst STRING_TYPES = ['string', 'text', 'uid', 'email', 'enumeration', 'richtext'];\nconst NUMBER_TYPES = ['biginteger', 'integer', 'decimal', 'float'];\n\nexport const isString = (type: string) => STRING_TYPES.includes(type);\nexport const isNumber = (type: string) => NUMBER_TYPES.includes(type);\nexport const isScalar = (type: string) => SCALAR_TYPES.includes(type);\nexport const isRelation = (type: string) => type === 'relation';\nexport const isScalarAttribute = (attribute: Attribute): attribute is ScalarAttribute =>\n isScalar(attribute.type);\nexport const isRelationalAttribute = (attribute: Attribute): attribute is RelationalAttribute =>\n isRelation(attribute.type);\n"],"names":["SCALAR_TYPES","STRING_TYPES","NUMBER_TYPES","isString","type","includes","isNumber","isScalar","isRelation","isScalarAttribute","attribute","isRelationalAttribute"],"mappings":"AAEA,MAAMA,YAAAA,GAAe;AACnB,IAAA,YAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,SAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,YAAAA,GAAe;AAAC,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,KAAA;AAAO,IAAA,OAAA;AAAS,IAAA,aAAA;AAAe,IAAA;AAAW,CAAA;AAClF,MAAMC,YAAAA,GAAe;AAAC,IAAA,YAAA;AAAc,IAAA,SAAA;AAAW,IAAA,SAAA;AAAW,IAAA;AAAQ,CAAA;MAErDC,QAAAA,GAAW,CAACC,OAAiBH,YAAAA,CAAaI,QAAQ,CAACD,IAAAA;MACnDE,QAAAA,GAAW,CAACF,OAAiBF,YAAAA,CAAaG,QAAQ,CAACD,IAAAA;MACnDG,QAAAA,GAAW,CAACH,OAAiBJ,YAAAA,CAAaK,QAAQ,CAACD,IAAAA;AACzD,MAAMI,UAAAA,GAAa,CAACJ,IAAAA,GAAiBA,SAAS;MACxCK,iBAAAA,GAAoB,CAACC,YAChCH,QAAAA,CAASG,SAAAA,CAAUN,IAAI;MACZO,qBAAAA,GAAwB,CAACD,YACpCF,UAAAA,CAAWE,SAAAA,CAAUN,IAAI;;;;"}
1
+ {"version":3,"file":"types.mjs","sources":["../../src/utils/types.ts"],"sourcesContent":["import type { Attribute, ScalarAttribute, RelationalAttribute } from '../types';\n\nconst SCALAR_TYPES = new Set([\n 'increments',\n 'password',\n 'email',\n 'string',\n 'uid',\n 'richtext',\n 'text',\n 'json',\n 'enumeration',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n 'blocks',\n]);\n\nconst STRING_TYPES = new Set(['string', 'text', 'uid', 'email', 'enumeration', 'richtext']);\nconst NUMBER_TYPES = new Set(['biginteger', 'integer', 'decimal', 'float']);\n\nexport const isString = (type: string) => STRING_TYPES.has(type);\nexport const isNumber = (type: string) => NUMBER_TYPES.has(type);\nexport const isScalar = (type: string) => SCALAR_TYPES.has(type);\nexport const isRelation = (type: string) => type === 'relation';\nexport const isScalarAttribute = (attribute: Attribute): attribute is ScalarAttribute =>\n isScalar(attribute.type);\nexport const isRelationalAttribute = (attribute: Attribute): attribute is RelationalAttribute =>\n isRelation(attribute.type);\n"],"names":["SCALAR_TYPES","Set","STRING_TYPES","NUMBER_TYPES","isString","type","has","isNumber","isScalar","isRelation","isScalarAttribute","attribute","isRelationalAttribute"],"mappings":"AAEA,MAAMA,YAAAA,GAAe,IAAIC,GAAAA,CAAI;AAC3B,IAAA,YAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,SAAA;AACA,IAAA;AACD,CAAA,CAAA;AAED,MAAMC,YAAAA,GAAe,IAAID,GAAAA,CAAI;AAAC,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,KAAA;AAAO,IAAA,OAAA;AAAS,IAAA,aAAA;AAAe,IAAA;AAAW,CAAA,CAAA;AAC1F,MAAME,YAAAA,GAAe,IAAIF,GAAAA,CAAI;AAAC,IAAA,YAAA;AAAc,IAAA,SAAA;AAAW,IAAA,SAAA;AAAW,IAAA;AAAQ,CAAA,CAAA;MAE7DG,QAAAA,GAAW,CAACC,OAAiBH,YAAAA,CAAaI,GAAG,CAACD,IAAAA;MAC9CE,QAAAA,GAAW,CAACF,OAAiBF,YAAAA,CAAaG,GAAG,CAACD,IAAAA;MAC9CG,QAAAA,GAAW,CAACH,OAAiBL,YAAAA,CAAaM,GAAG,CAACD,IAAAA;AACpD,MAAMI,UAAAA,GAAa,CAACJ,IAAAA,GAAiBA,SAAS;MACxCK,iBAAAA,GAAoB,CAACC,YAChCH,QAAAA,CAASG,SAAAA,CAAUN,IAAI;MACZO,qBAAAA,GAAwB,CAACD,YACpCF,UAAAA,CAAWE,SAAAA,CAAUN,IAAI;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/database",
3
- "version": "5.58.0",
3
+ "version": "5.59.0",
4
4
  "description": "Strapi's database layer",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -46,25 +46,25 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@paralleldrive/cuid2": "2.2.2",
49
- "@strapi/utils": "5.58.0",
49
+ "@strapi/utils": "5.59.0",
50
50
  "ajv": "8.20.0",
51
51
  "date-fns": "2.30.0",
52
52
  "debug": "4.3.4",
53
53
  "fs-extra": "11.3.4",
54
- "knex": "3.0.1",
54
+ "knex": "3.3.0",
55
55
  "lodash": "4.18.1",
56
56
  "semver": "7.7.4"
57
57
  },
58
58
  "devDependencies": {
59
- "@strapi/typescript-utils": "5.58.0",
59
+ "@strapi/typescript-utils": "5.59.0",
60
60
  "@types/fs-extra": "11.0.4",
61
61
  "@types/jest": "29.5.2",
62
62
  "@types/node": "20.19.41",
63
- "eslint-config-custom": "5.58.0",
63
+ "eslint-config-custom": "5.59.0",
64
64
  "jest": "29.6.0",
65
- "tsconfig": "5.58.0",
65
+ "tsconfig": "5.59.0",
66
66
  "vitest": "catalog:",
67
- "vitest-config": "5.58.0"
67
+ "vitest-config": "5.59.0"
68
68
  },
69
69
  "engines": {
70
70
  "node": ">=20.0.0 <=26.x.x",