@lossless.org/client 0.1.1 → 1.1.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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/core/drivers.d.ts +17 -0
- package/dist_ts/core/drivers.js +27 -0
- package/dist_ts/core/interfaces.d.ts +1 -1
- package/dist_ts/index.d.ts +2 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/nosqldb/classes.atomicupdate.d.ts +21 -0
- package/dist_ts/nosqldb/classes.atomicupdate.js +41 -1
- package/dist_ts/nosqldb/classes.collection.d.ts +31 -0
- package/dist_ts/nosqldb/classes.collection.js +120 -13
- package/dist_ts/nosqldb/classes.doc.d.ts +58 -0
- package/dist_ts/nosqldb/classes.doc.js +287 -22
- package/dist_ts/nosqldb/classes.ordinarypersistence.d.ts +6 -0
- package/dist_ts/nosqldb/classes.ordinarypersistence.js +7 -1
- package/dist_ts/nosqldb/index.d.ts +2 -0
- package/dist_ts/nosqldb/index.js +2 -1
- package/dist_ts/nosqldb/lineage.d.ts +13 -0
- package/dist_ts/nosqldb/lineage.js +13 -0
- package/dist_ts/objectstorage/classes.bucket.js +34 -36
- package/dist_ts/plugins.js +6 -4
- package/package.json +24 -7
- package/readme.md +30 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/core/drivers.ts +43 -0
- package/ts/core/interfaces.ts +1 -1
- package/ts/index.ts +2 -0
- package/ts/nosqldb/classes.atomicupdate.ts +67 -0
- package/ts/nosqldb/classes.collection.ts +181 -10
- package/ts/nosqldb/classes.doc.ts +525 -19
- package/ts/nosqldb/classes.ordinarypersistence.ts +8 -0
- package/ts/nosqldb/index.ts +2 -0
- package/ts/nosqldb/lineage.ts +25 -0
- package/ts/objectstorage/classes.bucket.ts +39 -43
- package/ts/plugins.ts +6 -3
|
@@ -20,6 +20,14 @@ export interface IOrdinaryPersistencePolicy {
|
|
|
20
20
|
const policySymbol = Symbol.for('@push.rocks/smartdata.ordinaryPersistencePolicy');
|
|
21
21
|
const exactSymbol = Symbol.for('@push.rocks/smartdata.exactPersistencePolicy');
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Reports whether a model opted into exact persistence. Exact persistence owns
|
|
25
|
+
* the stored `_id` as a MongoDB ObjectId, so options that hand the primary key
|
|
26
|
+
* to a declared identity field must refuse those models by name.
|
|
27
|
+
*/
|
|
28
|
+
export const hasExactPersistencePolicy = (modelArg: any): boolean =>
|
|
29
|
+
Boolean(modelArg?.[exactSymbol]);
|
|
30
|
+
|
|
23
31
|
export const getOrdinaryPersistencePolicy = (modelArg: any): IOrdinaryPersistencePolicy | undefined => {
|
|
24
32
|
const policy = modelArg?.[policySymbol] as IOrdinaryPersistencePolicy | undefined;
|
|
25
33
|
if (policy && modelArg[exactSymbol]) {
|
package/ts/nosqldb/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ import './shim.js';
|
|
|
3
3
|
|
|
4
4
|
export { NoSqlConnection } from './classes.connection.js';
|
|
5
5
|
export type { INoSqlConnectionOptions } from './classes.connection.js';
|
|
6
|
+
export { nosqldbLineage } from './lineage.js';
|
|
7
|
+
export type { INosqldbLineage } from './lineage.js';
|
|
6
8
|
|
|
7
9
|
export * from './classes.db.js';
|
|
8
10
|
export * from './classes.mongoadministration.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provenance of the vendored document implementation. Fixes land in this package; the upstream package is no longer a
|
|
3
|
+
* release channel, so the baseline states exactly which upstream state consumers inherit and where this fork departs.
|
|
4
|
+
*/
|
|
5
|
+
export interface INosqldbLineage {
|
|
6
|
+
readonly upstreamPackage: string;
|
|
7
|
+
readonly upstreamVersion: string;
|
|
8
|
+
/** Upstream release commit this tree was copied from; it is reachable in this repository's history. */
|
|
9
|
+
readonly upstreamCommit: string;
|
|
10
|
+
readonly forkedOn: string;
|
|
11
|
+
readonly deviations: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const nosqldbLineage: INosqldbLineage = Object.freeze({
|
|
15
|
+
upstreamPackage: '@push.rocks/smartdata',
|
|
16
|
+
upstreamVersion: '11.14.2',
|
|
17
|
+
upstreamCommit: '9868817a63de72caef787bd8e68bac3deb9d6131',
|
|
18
|
+
forkedOn: '2026-09-10',
|
|
19
|
+
deviations: Object.freeze([
|
|
20
|
+
'classes.connection.ts adds NoSqlConnection with the client backend, capability and readiness contract.',
|
|
21
|
+
'index.ts exports NoSqlConnection, INoSqlConnectionOptions and this lineage constant.',
|
|
22
|
+
'classes.collection.ts refuses watch() when the connected backend reports change streams as unsupported.',
|
|
23
|
+
'The package version file is dropped; versioning belongs to @lossless.org/client.',
|
|
24
|
+
]),
|
|
25
|
+
});
|
|
@@ -193,19 +193,17 @@ export class Bucket {
|
|
|
193
193
|
): Promise<File> {
|
|
194
194
|
try {
|
|
195
195
|
const reducedPath = await helpers.reducePathDescriptorToPath(optionsArg);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
`
|
|
206
|
-
|
|
207
|
-
} else {
|
|
208
|
-
console.log(`Creating new object at path '${reducedPath}' in bucket '${this.name}'.`);
|
|
196
|
+
if (optionsArg.overwrite !== true) {
|
|
197
|
+
const exists = await this.fastExists({ path: reducedPath });
|
|
198
|
+
|
|
199
|
+
if (exists) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
`Object already exists at path '${reducedPath}' in bucket '${this.name}'. ` +
|
|
202
|
+
`Set overwrite:true to replace it.`
|
|
203
|
+
);
|
|
204
|
+
} else {
|
|
205
|
+
console.log(`Creating new object at path '${reducedPath}' in bucket '${this.name}'.`);
|
|
206
|
+
}
|
|
209
207
|
}
|
|
210
208
|
|
|
211
209
|
const command = new plugins.s3.PutObjectCommand({
|
|
@@ -525,42 +523,40 @@ export class Bucket {
|
|
|
525
523
|
};
|
|
526
524
|
let putDispatched = false;
|
|
527
525
|
try {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
await operation.runProvider(() => operation.client.send(
|
|
531
|
-
new plugins.s3.HeadObjectCommand({
|
|
532
|
-
Bucket: operation.bucketName,
|
|
533
|
-
Key: optionsArg.path,
|
|
534
|
-
}),
|
|
535
|
-
{ abortSignal: operation.signal },
|
|
536
|
-
));
|
|
537
|
-
exists = true;
|
|
538
|
-
} catch (error: any) {
|
|
526
|
+
if (optionsArg.overwrite !== true) {
|
|
527
|
+
let exists: boolean;
|
|
539
528
|
try {
|
|
540
|
-
operation.
|
|
541
|
-
|
|
542
|
-
|
|
529
|
+
await operation.runProvider(() => operation.client.send(
|
|
530
|
+
new plugins.s3.HeadObjectCommand({
|
|
531
|
+
Bucket: operation.bucketName,
|
|
532
|
+
Key: optionsArg.path,
|
|
533
|
+
}),
|
|
534
|
+
{ abortSignal: operation.signal },
|
|
535
|
+
));
|
|
536
|
+
exists = true;
|
|
537
|
+
} catch (error: any) {
|
|
538
|
+
try {
|
|
539
|
+
operation.assertCurrent();
|
|
540
|
+
} catch (abortError) {
|
|
541
|
+
throw abortError;
|
|
542
|
+
}
|
|
543
|
+
if (error?.name === 'NotFound') {
|
|
544
|
+
exists = false;
|
|
545
|
+
} else {
|
|
546
|
+
throw error;
|
|
547
|
+
}
|
|
543
548
|
}
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
|
|
550
|
+
if (exists) {
|
|
551
|
+
throw new Error(
|
|
552
|
+
`Object already exists at path '${optionsArg.path}' in bucket '${this.name}'. ` +
|
|
553
|
+
`Set overwrite:true to replace it.`
|
|
554
|
+
);
|
|
546
555
|
} else {
|
|
547
|
-
|
|
556
|
+
console.log(`Creating new object at path '${optionsArg.path}' in bucket '${this.name}'.`);
|
|
548
557
|
}
|
|
549
558
|
}
|
|
550
559
|
|
|
551
|
-
if (exists && !optionsArg.overwrite) {
|
|
552
|
-
throw new Error(
|
|
553
|
-
`Object already exists at path '${optionsArg.path}' in bucket '${this.name}'. ` +
|
|
554
|
-
`Set overwrite:true to replace it.`
|
|
555
|
-
);
|
|
556
|
-
} else if (exists && optionsArg.overwrite) {
|
|
557
|
-
console.log(
|
|
558
|
-
`Overwriting existing object at path '${optionsArg.path}' in bucket '${this.name}'.`
|
|
559
|
-
);
|
|
560
|
-
} else {
|
|
561
|
-
console.log(`Creating new object at path '${optionsArg.path}' in bucket '${this.name}'.`);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
560
|
sourceOwnershipStarted = true;
|
|
565
561
|
uploadStream = optionsArg.readableStream instanceof plugins.stream.Readable
|
|
566
562
|
? optionsArg.readableStream
|
package/ts/plugins.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { requireDriver } from './core/drivers.js';
|
|
2
|
+
|
|
3
|
+
// Family modules load lazily, so an unconfigured family never resolves its driver package.
|
|
1
4
|
export const loadNoSql = () => import('./nosqldb/classes.connection.js');
|
|
2
|
-
export const loadObjects = () => import('./objectstorage/classes.connection.js');
|
|
3
|
-
export const loadSql = () => import('./sqldb/classes.sqlconnection.js');
|
|
4
|
-
export const loadClickHouse = () => import('./sqldb/classes.clickhouseconnection.js');
|
|
5
|
+
export const loadObjects = () => import('./objectstorage/classes.connection.js').catch(requireDriver('s3'));
|
|
6
|
+
export const loadSql = () => import('./sqldb/classes.sqlconnection.js').catch(requireDriver('mariadb'));
|
|
7
|
+
export const loadClickHouse = () => import('./sqldb/classes.clickhouseconnection.js').catch(requireDriver('clickhouse'));
|