@workglow/postgres 0.2.36 → 0.2.37
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.
- package/dist/job-queue/PostgresJobStore.d.ts +29 -0
- package/dist/job-queue/PostgresJobStore.d.ts.map +1 -0
- package/dist/job-queue/PostgresMessageQueue.d.ts +38 -0
- package/dist/job-queue/PostgresMessageQueue.d.ts.map +1 -0
- package/dist/job-queue/PostgresQueueStorage.d.ts +41 -10
- package/dist/job-queue/PostgresQueueStorage.d.ts.map +1 -1
- package/dist/job-queue/PostgresRateLimiterStorage.d.ts +1 -2
- package/dist/job-queue/PostgresRateLimiterStorage.d.ts.map +1 -1
- package/dist/job-queue/browser.js +401 -53
- package/dist/job-queue/browser.js.map +11 -8
- package/dist/job-queue/common.d.ts +3 -0
- package/dist/job-queue/common.d.ts.map +1 -1
- package/dist/job-queue/createPostgresQueue.d.ts +22 -0
- package/dist/job-queue/createPostgresQueue.d.ts.map +1 -0
- package/dist/job-queue/node.js +401 -53
- package/dist/job-queue/node.js.map +11 -8
- package/dist/migrations/PostgresMigrationRunner.d.ts +1 -1
- package/dist/migrations/PostgresMigrationRunner.d.ts.map +1 -1
- package/dist/migrations/postgresQueueMigrations.d.ts +9 -1
- package/dist/migrations/postgresQueueMigrations.d.ts.map +1 -1
- package/dist/migrations/postgresRateLimiterMigrations.d.ts +1 -1
- package/dist/migrations/postgresRateLimiterMigrations.d.ts.map +1 -1
- package/dist/storage/PostgresKvStorage.d.ts +1 -1
- package/dist/storage/PostgresKvStorage.d.ts.map +1 -1
- package/dist/storage/PostgresTabularStorage.d.ts +1 -1
- package/dist/storage/PostgresTabularStorage.d.ts.map +1 -1
- package/dist/storage/PostgresVectorStorage.d.ts +1 -1
- package/dist/storage/PostgresVectorStorage.d.ts.map +1 -1
- package/dist/storage/browser.js +28 -12
- package/dist/storage/browser.js.map +5 -5
- package/dist/storage/node.js +28 -12
- package/dist/storage/node.js.map +6 -6
- package/dist/text/PostgresFtsTextIndex.d.ts.map +1 -1
- package/dist/text/browser.js.map +2 -2
- package/dist/text/node.js.map +2 -2
- package/package.json +7 -7
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import type { Pool } from "@workglow/postgres/storage";
|
|
7
|
+
import type { IVectorStorage, VectorIndexOptions, VectorSearchOptions } from "@workglow/storage";
|
|
7
8
|
import type { DataPortSchemaObject, FromSchema, TypedArray, TypedArrayConstructor, TypedArraySchemaOptions } from "@workglow/util/schema";
|
|
8
9
|
import { PostgresTabularStorage } from "./PostgresTabularStorage";
|
|
9
|
-
import type { IVectorStorage, VectorIndexOptions, VectorSearchOptions } from "@workglow/storage";
|
|
10
10
|
export declare class PostgresVectorStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Metadata extends Record<string, unknown> = Record<string, unknown>, Entity = FromSchema<Schema, TypedArraySchemaOptions>> extends PostgresTabularStorage<Schema, PrimaryKeyNames, Entity> implements IVectorStorage<Metadata, Schema, Entity, PrimaryKeyNames> {
|
|
11
11
|
private vectorDimensions;
|
|
12
12
|
private readonly vectorCtor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresVectorStorage.d.ts","sourceRoot":"","sources":["../../src/storage/PostgresVectorStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgresVectorStorage.d.ts","sourceRoot":"","sources":["../../src/storage/PostgresVectorStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OA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C;IAEe,mBAAmB,IAAI,MAAM,CAE5C;IAED,4EAA4E;IAC5E,UAAmB,qBAAqB,IAAI,kBAAkB,CAE7D;IAED,sEAAsE;IACtE,OAAO,KAAK,QAAQ,GAEnB;IAED;;;;;;OAMG;IACH,OAAO,KAAK,gBAAgB,GAS3B;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;;;;;;OAUG;IACI,cAAc,IAAI;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAK9D;IAEY,gBAAgB,CAC3B,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,mBAAmB,CAAC,QAAQ,CAAM,GAC1C,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CA4F5C;IAED;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;YAcxB,cAAc;IA6B5B,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,aAAa;CAQtB"}
|
package/dist/storage/browser.js
CHANGED
|
@@ -141,19 +141,32 @@ var Postgres = {
|
|
|
141
141
|
createPool
|
|
142
142
|
};
|
|
143
143
|
// src/storage/PostgresKvStorage.ts
|
|
144
|
+
import {
|
|
145
|
+
DefaultKeyValueKey,
|
|
146
|
+
DefaultKeyValueSchema,
|
|
147
|
+
KvViaTabularStorage
|
|
148
|
+
} from "@workglow/storage";
|
|
144
149
|
import { createServiceToken as createServiceToken2 } from "@workglow/util";
|
|
145
150
|
|
|
146
151
|
// src/storage/PostgresTabularStorage.ts
|
|
147
|
-
import { createServiceToken } from "@workglow/util";
|
|
148
152
|
import {
|
|
149
153
|
BaseSqlTabularStorage,
|
|
150
154
|
buildSearchWhere,
|
|
151
155
|
MIGRATIONS_TABLE,
|
|
156
|
+
pickCoveringIndex,
|
|
152
157
|
PostgresDialect,
|
|
153
|
-
SqlTabularMigrationApplier
|
|
154
|
-
pickCoveringIndex
|
|
158
|
+
SqlTabularMigrationApplier
|
|
155
159
|
} from "@workglow/storage";
|
|
160
|
+
import { createServiceToken } from "@workglow/util";
|
|
156
161
|
var POSTGRES_TABULAR_REPOSITORY = createServiceToken("storage.tabularRepository.postgres");
|
|
162
|
+
var TYPED_ARRAY_CTORS = {
|
|
163
|
+
Float32Array,
|
|
164
|
+
Float64Array,
|
|
165
|
+
Int8Array,
|
|
166
|
+
Uint8Array,
|
|
167
|
+
Int16Array,
|
|
168
|
+
Uint16Array
|
|
169
|
+
};
|
|
157
170
|
function assertPositiveInt(value, label) {
|
|
158
171
|
if (value === undefined)
|
|
159
172
|
return;
|
|
@@ -392,12 +405,20 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
|
|
|
392
405
|
if (typeof actualType !== "boolean" && this.isVectorFormat(actualType.format)) {
|
|
393
406
|
if (typeof value === "string") {
|
|
394
407
|
try {
|
|
395
|
-
const
|
|
396
|
-
|
|
408
|
+
const parsed = JSON.parse(value);
|
|
409
|
+
const nums = Array.isArray(parsed) ? parsed : Object.values(parsed);
|
|
410
|
+
const ctorName = typeof actualType.format === "string" && actualType.format !== "TypedArray" ? actualType.format.slice("TypedArray:".length) : "Float32Array";
|
|
411
|
+
const Ctor = TYPED_ARRAY_CTORS[ctorName] ?? Float32Array;
|
|
412
|
+
return new Ctor(nums);
|
|
397
413
|
} catch (e) {
|
|
398
414
|
console.warn(`Failed to parse vector for column ${column}:`, e);
|
|
399
415
|
}
|
|
400
416
|
}
|
|
417
|
+
if (value && typeof value === "object" && Array.isArray(value)) {
|
|
418
|
+
const ctorName = typeof actualType.format === "string" && actualType.format !== "TypedArray" ? actualType.format.slice("TypedArray:".length) : "Float32Array";
|
|
419
|
+
const Ctor = TYPED_ARRAY_CTORS[ctorName] ?? Float32Array;
|
|
420
|
+
return new Ctor(value);
|
|
421
|
+
}
|
|
401
422
|
if (value && typeof value === "object") {
|
|
402
423
|
return value;
|
|
403
424
|
}
|
|
@@ -1075,11 +1096,6 @@ class PostgresTabularMigrationApplierImpl extends SqlTabularMigrationApplier {
|
|
|
1075
1096
|
}
|
|
1076
1097
|
|
|
1077
1098
|
// src/storage/PostgresKvStorage.ts
|
|
1078
|
-
import {
|
|
1079
|
-
DefaultKeyValueKey,
|
|
1080
|
-
DefaultKeyValueSchema,
|
|
1081
|
-
KvViaTabularStorage
|
|
1082
|
-
} from "@workglow/storage";
|
|
1083
1099
|
var POSTGRES_KV_REPOSITORY = createServiceToken2("storage.kvRepository.postgres");
|
|
1084
1100
|
|
|
1085
1101
|
class PostgresKvStorage extends KvViaTabularStorage {
|
|
@@ -1094,13 +1110,13 @@ class PostgresKvStorage extends KvViaTabularStorage {
|
|
|
1094
1110
|
}
|
|
1095
1111
|
}
|
|
1096
1112
|
// src/storage/PostgresVectorStorage.ts
|
|
1097
|
-
import { cosineSimilarity } from "@workglow/util/schema";
|
|
1098
1113
|
import {
|
|
1099
1114
|
PostgresDialect as PostgresDialect2,
|
|
1100
1115
|
StorageValidationError,
|
|
1101
1116
|
getMetadataProperty,
|
|
1102
1117
|
getVectorProperty
|
|
1103
1118
|
} from "@workglow/storage";
|
|
1119
|
+
import { cosineSimilarity } from "@workglow/util/schema";
|
|
1104
1120
|
var SAFE_IDENTIFIER_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
1105
1121
|
|
|
1106
1122
|
class PostgresVectorStorage extends PostgresTabularStorage {
|
|
@@ -1271,4 +1287,4 @@ export {
|
|
|
1271
1287
|
POSTGRES_KV_REPOSITORY
|
|
1272
1288
|
};
|
|
1273
1289
|
|
|
1274
|
-
//# debugId=
|
|
1290
|
+
//# debugId=142F3D7909204DEC64756E2164756E21
|