Skip to content

Commit a1c3838

Browse files
authored
ESM update hotfix (#101)
* hotfix for broken types * clean up & speed up build script * change Coll => Collection prefixes as per vals suggestion * check to make sure esm & cjs exports are the same * build step to remove #private from rollup .d.ts
1 parent d5f2a30 commit a1c3838

File tree

36 files changed

+445
-484
lines changed

36 files changed

+445
-484
lines changed

etc/astra-db-ts.api.md

Lines changed: 77 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```ts
66

77
import { BigNumber } from 'bignumber.js';
8-
import { CollSerDesConfig as CollSerDesConfig_2 } from '../../documents/collections/ser-des/ser-des.js';
8+
import { CollectionSerDesConfig as CollectionSerDesConfig_2 } from '../../documents/collections/ser-des/ser-des.js';
99
import { Decoder } from 'decoders';
1010
import type { DecoderType } from 'decoders';
1111
import { Monoid as Monoid_2 } from '../../lib/opts-handler.js';
@@ -319,6 +319,8 @@ export interface BaseSerDesCtx {
319319
target: SerDesTarget;
320320
}
321321

322+
export { BigNumber }
323+
322324
// @public
323325
export const blob: (blob: DataAPIBlobLike) => DataAPIBlob;
324326

@@ -350,54 +352,6 @@ export interface Camel2SnakeCaseOptions {
350352
transformNested?: boolean | ((path: KeyTransformerCtx) => boolean);
351353
}
352354

353-
// @public (undocumented)
354-
export type CollCodec<Class extends CollCodecClass> = InstanceType<Class>;
355-
356-
// @public (undocumented)
357-
export interface CollCodecClass {
358-
// (undocumented)
359-
[$DeserializeForCollection]: SerDesFn<CollDesCtx>;
360-
// (undocumented)
361-
new (...args: any[]): {
362-
[$SerializeForCollection]: (ctx: CollSerCtx) => ReturnType<SerDesFn<any>>;
363-
};
364-
}
365-
366-
// @public (undocumented)
367-
export class CollCodecs {
368-
// Warning: (ae-forgotten-export) The symbol "CollCustomCodecOpts" needs to be exported by the entry point index.d.ts
369-
//
370-
// (undocumented)
371-
static custom(opts: CollCustomCodecOpts): RawCollCodecs;
372-
// (undocumented)
373-
static Defaults: {
374-
$date: RawCollCodecs;
375-
$vector: RawCollCodecs;
376-
$uuid: RawCollCodecs;
377-
$objectId: RawCollCodecs;
378-
};
379-
// Warning: (ae-forgotten-export) The symbol "CollNominalCodecOpts" needs to be exported by the entry point index.d.ts
380-
//
381-
// (undocumented)
382-
static forId(optsOrClass: CollNominalCodecOpts & {
383-
class?: SomeConstructor;
384-
} | CollCodecClass): RawCollCodecs;
385-
// (undocumented)
386-
static forName(name: string, optsOrClass: CollNominalCodecOpts | CollCodecClass): RawCollCodecs;
387-
// (undocumented)
388-
static forPath(path: (string | number)[], optsOrClass: CollNominalCodecOpts | CollCodecClass): RawCollCodecs;
389-
// Warning: (ae-forgotten-export) The symbol "CollTypeCodecOpts" needs to be exported by the entry point index.d.ts
390-
//
391-
// (undocumented)
392-
static forType(type: string, optsOrClass: CollTypeCodecOpts | CollCodecClass): RawCollCodecs;
393-
}
394-
395-
// @public (undocumented)
396-
export interface CollDesCtx extends BaseDesCtx<CollDesCtx> {
397-
// (undocumented)
398-
getNumRepForPath?: GetCollNumRepFn;
399-
}
400-
401355
// @public
402356
export class Collection<WSchema extends SomeDoc = SomeDoc, RSchema extends WithId<SomeDoc> = FoundDoc<WSchema>> {
403357
// Warning: (ae-forgotten-export) The symbol "DataAPIHttpClient" needs to be exported by the entry point index.d.ts
@@ -445,6 +399,48 @@ export type CollectionArrayUpdate<Schema> = {
445399
[K in keyof Schema as any[] extends Schema[K] ? K : never]?: PickArrayTypes<Schema[K]>;
446400
};
447401

402+
// @public (undocumented)
403+
export type CollectionCodec<Class extends CollectionCodecClass> = InstanceType<Class>;
404+
405+
// @public (undocumented)
406+
export interface CollectionCodecClass {
407+
// (undocumented)
408+
[$DeserializeForCollection]: SerDesFn<CollectionDesCtx>;
409+
// (undocumented)
410+
new (...args: any[]): {
411+
[$SerializeForCollection]: (ctx: CollectionSerCtx) => ReturnType<SerDesFn<any>>;
412+
};
413+
}
414+
415+
// @public (undocumented)
416+
export class CollectionCodecs {
417+
// Warning: (ae-forgotten-export) The symbol "CollCustomCodecOpts" needs to be exported by the entry point index.d.ts
418+
//
419+
// (undocumented)
420+
static custom(opts: CollCustomCodecOpts): RawCollCodecs;
421+
// (undocumented)
422+
static Defaults: {
423+
$date: RawCollCodecs;
424+
$vector: RawCollCodecs;
425+
$uuid: RawCollCodecs;
426+
$objectId: RawCollCodecs;
427+
};
428+
// Warning: (ae-forgotten-export) The symbol "CollNominalCodecOpts" needs to be exported by the entry point index.d.ts
429+
//
430+
// (undocumented)
431+
static forId(optsOrClass: CollNominalCodecOpts & {
432+
class?: SomeConstructor;
433+
} | CollectionCodecClass): RawCollCodecs;
434+
// (undocumented)
435+
static forName(name: string, optsOrClass: CollNominalCodecOpts | CollectionCodecClass): RawCollCodecs;
436+
// (undocumented)
437+
static forPath(path: (string | number)[], optsOrClass: CollNominalCodecOpts | CollectionCodecClass): RawCollCodecs;
438+
// Warning: (ae-forgotten-export) The symbol "CollTypeCodecOpts" needs to be exported by the entry point index.d.ts
439+
//
440+
// (undocumented)
441+
static forType(type: string, optsOrClass: CollTypeCodecOpts | CollectionCodecClass): RawCollCodecs;
442+
}
443+
448444
// @public
449445
export type CollectionCurrentDate<Schema> = {
450446
[K in keyof Schema as Schema[K] extends Date | {
@@ -496,6 +492,12 @@ export interface CollectionDescriptor {
496492
name: string;
497493
}
498494

495+
// @public (undocumented)
496+
export interface CollectionDesCtx extends BaseDesCtx<CollectionDesCtx> {
497+
// (undocumented)
498+
getNumRepForPath?: GetCollNumRepFn;
499+
}
500+
499501
// @public
500502
export type CollectionFilter<Schema extends SomeDoc> = {
501503
[K in keyof ToDotNotation<NoId<Schema>>]?: CollectionFilterExpr<ToDotNotation<NoId<Schema>>[K]>;
@@ -585,7 +587,7 @@ export interface CollectionOptions extends WithKeyspace {
585587
embeddingApiKey?: string | EmbeddingHeadersProvider | null;
586588
logging?: DataAPILoggingConfig;
587589
// @beta
588-
serdes?: CollSerDesConfig;
590+
serdes?: CollectionSerDesConfig;
589591
timeoutDefaults?: Partial<TimeoutDescriptor>;
590592
}
591593

@@ -608,6 +610,20 @@ export type CollectionReplaceOneOptions = GenericReplaceOneOptions;
608610
// @public
609611
export type CollectionReplaceOneResult<RSchema> = GenericUpdateResult<IdOf<RSchema>, 0 | 1>;
610612

613+
// @public (undocumented)
614+
export interface CollectionSerCtx extends BaseSerCtx<CollectionSerCtx> {
615+
// (undocumented)
616+
bigNumsEnabled: boolean;
617+
}
618+
619+
// @public (undocumented)
620+
export interface CollectionSerDesConfig extends BaseSerDesConfig<CollectionSerCtx, CollectionDesCtx> {
621+
// (undocumented)
622+
codecs?: RawCollCodecs[];
623+
// (undocumented)
624+
enableBigNumbers?: GetCollNumRepFn | CollNumRepCfg;
625+
}
626+
611627
// @public
612628
export interface CollectionUpdateFilter<Schema extends SomeDoc> {
613629
$addToSet?: CollectionPush<Schema> & SomeDoc;
@@ -660,20 +676,6 @@ export type CollNumRep = 'number' | 'bigint' | 'bignumber' | 'string' | 'number_
660676
// @public (undocumented)
661677
export type CollNumRepCfg = Record<string, CollNumRep>;
662678

663-
// @public (undocumented)
664-
export interface CollSerCtx extends BaseSerCtx<CollSerCtx> {
665-
// (undocumented)
666-
bigNumsEnabled: boolean;
667-
}
668-
669-
// @public (undocumented)
670-
export interface CollSerDesConfig extends BaseSerDesConfig<CollSerCtx, CollDesCtx> {
671-
// (undocumented)
672-
codecs?: RawCollCodecs[];
673-
// (undocumented)
674-
enableBigNumbers?: GetCollNumRepFn | CollNumRepCfg;
675-
}
676-
677679
// @public
678680
export abstract class CommandEvent extends BaseDataAPIClientEvent {
679681
// Warning: (ae-forgotten-export) The symbol "DataAPIRequestInfo" needs to be exported by the entry point index.d.ts
@@ -1079,10 +1081,10 @@ export class DataAPITimeoutError extends DataAPIError {
10791081
}
10801082

10811083
// @public
1082-
export class DataAPIVector implements CollCodec<typeof DataAPIVector>, TableCodec<typeof DataAPIVector> {
1083-
static [$DeserializeForCollection](value: any, ctx: CollDesCtx): readonly [0, (DataAPIVector | undefined)?];
1084+
export class DataAPIVector implements CollectionCodec<typeof DataAPIVector>, TableCodec<typeof DataAPIVector> {
1085+
static [$DeserializeForCollection](value: any, ctx: CollectionDesCtx): readonly [0, (DataAPIVector | undefined)?];
10841086
static [$DeserializeForTable](value: any, ctx: TableDesCtx): readonly [0, (DataAPIVector | undefined)?];
1085-
[$SerializeForCollection](ctx: CollSerCtx): readonly [0, (number[] | {
1087+
[$SerializeForCollection](ctx: CollectionSerCtx): readonly [0, (number[] | {
10861088
$binary: string;
10871089
} | undefined)?];
10881090
[$SerializeForTable](ctx: TableSerCtx): readonly [0, (number[] | {
@@ -1179,7 +1181,7 @@ export interface DbOptions {
11791181

11801182
// @public
11811183
export interface DbSerDesConfig {
1182-
collection?: Omit<CollSerDesConfig, 'mutateInPlace'>;
1184+
collection?: Omit<CollectionSerDesConfig, 'mutateInPlace'>;
11831185
mutateInPlace?: boolean;
11841186
table?: Omit<TableSerDesConfig, 'mutateInPlace'>;
11851187
}
@@ -1619,7 +1621,7 @@ export abstract class KeyTransformer {
16191621
export const LIB_NAME = "astra-db-ts";
16201622

16211623
// @public
1622-
export const LIB_VERSION = "2.0.0-preview.3";
1624+
export const LIB_VERSION = "2.0.0-preview.4";
16231625

16241626
// @public
16251627
export interface ListAstraDatabasesOptions extends WithTimeout<'databaseAdminTimeoutMs'> {
@@ -1765,9 +1767,9 @@ export class NumCoercionError extends Error {
17651767
}
17661768

17671769
// @public
1768-
export class ObjectId implements CollCodec<typeof ObjectId> {
1769-
static [$DeserializeForCollection](value: any, ctx: CollDesCtx): readonly [0, (ObjectId | undefined)?];
1770-
[$SerializeForCollection](ctx: CollSerCtx): readonly [0, ({
1770+
export class ObjectId implements CollectionCodec<typeof ObjectId> {
1771+
static [$DeserializeForCollection](value: any, ctx: CollectionDesCtx): readonly [0, (ObjectId | undefined)?];
1772+
[$SerializeForCollection](ctx: CollectionSerCtx): readonly [0, ({
17711773
$objectId: string;
17721774
} | undefined)?];
17731775
constructor(id?: string | number | null, validate?: boolean);
@@ -2244,10 +2246,10 @@ export class UsernamePasswordTokenProvider extends TokenProvider {
22442246
}
22452247

22462248
// @public
2247-
export class UUID implements CollCodec<typeof UUID>, TableCodec<typeof UUID> {
2248-
static [$DeserializeForCollection](value: any, ctx: CollDesCtx): readonly [0, (UUID | undefined)?];
2249+
export class UUID implements CollectionCodec<typeof UUID>, TableCodec<typeof UUID> {
2250+
static [$DeserializeForCollection](value: any, ctx: CollectionDesCtx): readonly [0, (UUID | undefined)?];
22492251
static [$DeserializeForTable](value: any, ctx: TableDesCtx): readonly [0, (UUID | undefined)?];
2250-
[$SerializeForCollection](ctx: CollSerCtx): readonly [0, ({
2252+
[$SerializeForCollection](ctx: CollectionSerCtx): readonly [0, ({
22512253
$uuid: string;
22522254
} | undefined)?];
22532255
[$SerializeForTable](ctx: TableSerCtx): readonly [0, (string | undefined)?];
@@ -2316,9 +2318,6 @@ export interface WithTimeout<Timeouts extends keyof TimeoutDescriptor> {
23162318
timeout?: number | Pick<Partial<TimeoutDescriptor>, 'requestTimeoutMs' | Timeouts>;
23172319
}
23182320

2319-
2320-
export * from "bignumber.js";
2321-
23222321
// Warnings were encountered during analysis:
23232322
//
23242323
// dist/esm/documents/collections/ser-des/codecs.d.ts:41:9 - (ae-forgotten-export) The symbol "RawCollCodecs" needs to be exported by the entry point index.d.ts

examples/astra-db-ts.tgz

61 Bytes
Binary file not shown.

examples/browser/package-lock.json

Lines changed: 4 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/cloudflare-workers/package-lock.json

Lines changed: 4 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)