@instantdb/core 0.22.75 → 0.22.76
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/commonjs/Connection.d.ts +2 -1
- package/dist/commonjs/Connection.d.ts.map +1 -1
- package/dist/commonjs/Connection.js +26 -16
- package/dist/commonjs/Connection.js.map +1 -1
- package/dist/commonjs/Reactor.d.ts.map +1 -1
- package/dist/commonjs/Reactor.js +8 -1
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/commonjs/SyncTable.d.ts +10 -10
- package/dist/commonjs/SyncTable.d.ts.map +1 -1
- package/dist/commonjs/SyncTable.js.map +1 -1
- package/dist/commonjs/__types__/fieldsTypeTest.d.ts +2 -0
- package/dist/commonjs/__types__/fieldsTypeTest.d.ts.map +1 -0
- package/dist/commonjs/__types__/fieldsTypeTest.js +74 -0
- package/dist/commonjs/__types__/fieldsTypeTest.js.map +1 -0
- package/dist/commonjs/__types__/typeUtils.d.ts +20 -0
- package/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
- package/dist/commonjs/__types__/typeUtils.js +5 -0
- package/dist/commonjs/__types__/typeUtils.js.map +1 -0
- package/dist/commonjs/__types__/useDatesTypeTest.d.ts +2 -0
- package/dist/commonjs/__types__/useDatesTypeTest.d.ts.map +1 -0
- package/dist/commonjs/__types__/useDatesTypeTest.js +55 -0
- package/dist/commonjs/__types__/useDatesTypeTest.js.map +1 -0
- package/dist/commonjs/clientTypes.d.ts +1 -1
- package/dist/commonjs/clientTypes.d.ts.map +1 -1
- package/dist/commonjs/clientTypes.js.map +1 -1
- package/dist/commonjs/index.d.ts +15 -8
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +12 -7
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/queryTypes.d.ts +4 -4
- package/dist/commonjs/queryTypes.d.ts.map +1 -1
- package/dist/commonjs/queryTypes.js.map +1 -1
- package/dist/commonjs/schemaTypes.d.ts +2 -2
- package/dist/commonjs/schemaTypes.d.ts.map +1 -1
- package/dist/commonjs/schemaTypes.js.map +1 -1
- package/dist/esm/Connection.d.ts +2 -1
- package/dist/esm/Connection.d.ts.map +1 -1
- package/dist/esm/Connection.js +26 -16
- package/dist/esm/Connection.js.map +1 -1
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/Reactor.js +8 -1
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/esm/SyncTable.d.ts +10 -10
- package/dist/esm/SyncTable.d.ts.map +1 -1
- package/dist/esm/SyncTable.js.map +1 -1
- package/dist/esm/__types__/fieldsTypeTest.d.ts +2 -0
- package/dist/esm/__types__/fieldsTypeTest.d.ts.map +1 -0
- package/dist/esm/__types__/fieldsTypeTest.js +72 -0
- package/dist/esm/__types__/fieldsTypeTest.js.map +1 -0
- package/dist/esm/__types__/typeUtils.d.ts +20 -0
- package/dist/esm/__types__/typeUtils.d.ts.map +1 -0
- package/dist/esm/__types__/typeUtils.js +4 -0
- package/dist/esm/__types__/typeUtils.js.map +1 -0
- package/dist/esm/__types__/useDatesTypeTest.d.ts +2 -0
- package/dist/esm/__types__/useDatesTypeTest.d.ts.map +1 -0
- package/dist/esm/__types__/useDatesTypeTest.js +53 -0
- package/dist/esm/__types__/useDatesTypeTest.js.map +1 -0
- package/dist/esm/clientTypes.d.ts +1 -1
- package/dist/esm/clientTypes.d.ts.map +1 -1
- package/dist/esm/clientTypes.js.map +1 -1
- package/dist/esm/index.d.ts +15 -8
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +12 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/queryTypes.d.ts +4 -4
- package/dist/esm/queryTypes.d.ts.map +1 -1
- package/dist/esm/queryTypes.js.map +1 -1
- package/dist/esm/schemaTypes.d.ts +2 -2
- package/dist/esm/schemaTypes.d.ts.map +1 -1
- package/dist/esm/schemaTypes.js.map +1 -1
- package/dist/standalone/index.js +104 -92
- package/dist/standalone/index.umd.cjs +2 -2
- package/package.json +4 -3
- package/src/Connection.ts +28 -18
- package/src/Reactor.js +7 -1
- package/src/SyncTable.ts +10 -10
- package/{__tests__/src → src/__types__}/fieldsTypeTest.ts +1 -1
- package/src/__types__/typeUtils.ts +39 -0
- package/{__tests__/src → src/__types__}/useDatesTypeTest.ts +1 -2
- package/src/clientTypes.ts +1 -1
- package/src/index.ts +36 -31
- package/src/queryTypes.ts +4 -4
- package/src/schemaTypes.ts +2 -5
- package/tsconfig.json +1 -1
- package/tsconfig.test.json +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaTypes.js","sourceRoot":"","sources":["../../src/schemaTypes.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAW;IAOtB,YACS,SAAqB,EACrB,QAAoB,EACpB,SAAoB,EAEpB,SAIH,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;QAR9B,cAAS,GAAT,SAAS,CAAY;QACrB,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAW;QAEpB,WAAM,GAAN,MAAM,CAIwB;QAXhC,aAAQ,GAA4B,EAAE,CAAC;IAY3C,CAAC;IAEJ;;;;OAIG;IACH,cAAc;QACZ,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,KAAwB,EACxB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,KAAK,EACL,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,kCAET,IAAI,CAAC,MAAM,KACd,MAAM,EAAE,IAAI,IAEf,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,kCAEC,IAAI,CAAC,MAAM,KACd,OAAO,EAAE,IAAI,IAEhB,CAAC;IACJ,CAAC;CAQF;AAED,MAAM,OAAO,WAAW;IAItB,YACS,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;IAC5B,CAAC;CACL;AAuBD,MAAM,OAAO,SAAS;IAKpB,YACS,KAAY,EACZ,KAAY;QADZ,UAAK,GAAL,KAAK,CAAO;QACZ,UAAK,GAAL,KAAK,CAAO;IAClB,CAAC;IAEJ,MAAM;QACJ,OAAO,IAAI,SAAS,CAAwB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;CACF;AAsQD,MAAM,OAAO,gBAAgB;IAM3B,YACS,QAAkB,EAClB,KAAY,EACZ,KAAY;QAFZ,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAO;QACZ,UAAK,GAAL,KAAK,CAAO;IAClB,CAAC;IAEJ;;;;;;;;;;;;;;;;;;OAkBG;IACH,cAAc;QAEZ,OAAO,IAAI,gBAAgB,CACzB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,EAAU,CACX,CAAC;IACJ,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAMvB,YACS,QAAkB,EAClB,KAAY;QADZ,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAO;IAClB,CAAC;IAEJ,cAAc;QACZ,OAAO,IAAI,YAAY,CACrB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,CACX,CAAC;IACJ,CAAC;CACF;AAqGD,MAAM,OAAO,uBAAwB,SAAQ,gBAI5C;CAAG","sourcesContent":["import type { RoomSchemaShape } from './presence.ts';\nimport { Expand } from './queryTypes.ts';\n\nexport class DataAttrDef<\n ValueType,\n IsRequired extends RequirementKind,\n IsIndexed extends boolean,\n> {\n public metadata: Record<string, unknown> = {};\n\n constructor(\n public valueType: ValueTypes,\n public required: IsRequired,\n public isIndexed: IsIndexed,\n\n public config: {\n indexed: boolean;\n unique: boolean;\n // clientValidator?: (value: ValueType) => boolean;\n } = { indexed: false, unique: false },\n ) {}\n\n /**\n * @deprecated Only use this temporarily for attributes that you want\n * to treat as required in frontend code but can’t yet mark as required\n * and enforced for backend\n */\n clientRequired() {\n return new DataAttrDef<ValueType, true, IsIndexed>(\n this.valueType,\n false as unknown as true,\n this.isIndexed,\n this.config,\n );\n }\n\n optional() {\n return new DataAttrDef<ValueType, false, IsIndexed>(\n this.valueType,\n false,\n this.isIndexed,\n this.config,\n );\n }\n\n unique() {\n return new DataAttrDef<ValueType, IsRequired, IsIndexed>(\n this.valueType,\n this.required,\n this.isIndexed,\n {\n ...this.config,\n unique: true,\n },\n );\n }\n\n indexed() {\n return new DataAttrDef<ValueType, IsRequired, true>(\n this.valueType,\n this.required,\n true,\n {\n ...this.config,\n indexed: true,\n },\n );\n }\n\n // clientValidate(clientValidator: (value: ValueType) => boolean) {\n // return new DataAttrDef(this.valueType, this.required, {\n // ...this.config,\n // clientValidator,\n // });\n // }\n}\n\nexport class LinkAttrDef<\n Cardinality extends CardinalityKind,\n EntityName extends string,\n> {\n constructor(\n public cardinality: Cardinality,\n public entityName: EntityName,\n ) {}\n}\n\nexport interface IContainEntitiesAndLinks<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n> {\n entities: Entities;\n links: Links;\n}\n\n// ==========\n// base types\n\nexport type ValueTypes = 'string' | 'number' | 'boolean' | 'date' | 'json';\n\nexport type CardinalityKind = 'one' | 'many';\n\n// true - force required\n// false - optional, not required\nexport type RequirementKind = true | false;\n\nexport type AttrsDefs = Record<string, DataAttrDef<any, any, any>>;\n\nexport class EntityDef<\n Attrs extends AttrsDefs,\n Links extends Record<string, LinkAttrDef<any, any>>,\n AsType,\n> {\n constructor(\n public attrs: Attrs,\n public links: Links,\n ) {}\n\n asType<_AsType extends Partial<MappedAttrs<Attrs, boolean>>>() {\n return new EntityDef<Attrs, Links, _AsType>(this.attrs, this.links);\n }\n}\n\nexport type EntityDefFromSchema<\n S extends IContainEntitiesAndLinks<any, any>,\n K extends keyof S['entities'],\n> = {\n [k in keyof S['entities'][K]['attrs']]: S['entities'][K] extends EntityDef<\n any,\n any,\n any\n >\n ? S['entities'][K]['attrs'][k]\n : never;\n};\n\nexport type EntitiesDef = Record<string, EntityDef<any, any, any>>;\n\nexport type LinksDef<Entities extends EntitiesDef> = Record<\n string,\n LinkDef<\n Entities,\n keyof Entities,\n string,\n CardinalityKind,\n keyof Entities,\n string,\n CardinalityKind\n >\n>;\n\nexport type LinkDef<\n Entities extends EntitiesDef,\n FwdEntity extends keyof Entities,\n FwdAttr extends string,\n FwdCardinality extends CardinalityKind,\n RevEntity extends keyof Entities,\n RevAttr extends string,\n RevCardinality extends CardinalityKind,\n> = {\n forward: {\n on: FwdEntity;\n label: FwdAttr;\n has: FwdCardinality;\n required?: RequirementKind;\n onDelete?: 'cascade';\n };\n reverse: {\n on: RevEntity;\n label: RevAttr;\n has: RevCardinality;\n onDelete?: 'cascade';\n };\n};\n\n// ==========\n// derived types\ntype IsEmptyOrIndexSignature<T> = keyof T extends never\n ? true\n : string extends keyof T\n ? true\n : false;\n\nexport type EntitiesWithLinks<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n> = {\n [EntityName in keyof Entities]: EntityDef<\n Entities[EntityName]['attrs'],\n EntityForwardLinksMap<EntityName, Entities, Links> &\n EntityReverseLinksMap<EntityName, Entities, Links>,\n Entities[EntityName] extends EntityDef<any, any, infer O>\n ? O extends void\n ? void\n : O\n : void\n >;\n};\n\ntype EntityForwardLinksMap<\n EntityName extends keyof Entities,\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n LinkIndexFwd = LinksIndexedByEntity<Entities, Links, 'reverse'>,\n> =\n IsEmptyOrIndexSignature<Links> extends true\n ? {}\n : EntityName extends keyof LinkIndexFwd\n ? {\n [LinkName in keyof LinkIndexFwd[EntityName]]: LinkIndexFwd[EntityName][LinkName] extends LinkDef<\n Entities,\n infer RelatedEntityName,\n any,\n any,\n any,\n any,\n infer Cardinality\n >\n ? {\n entityName: RelatedEntityName;\n cardinality: Cardinality;\n }\n : never;\n }\n : {};\n\ntype EntityReverseLinksMap<\n EntityName extends keyof Entities,\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n RevLinkIndex = LinksIndexedByEntity<Entities, Links, 'forward'>,\n> =\n IsEmptyOrIndexSignature<Links> extends true\n ? {}\n : EntityName extends keyof RevLinkIndex\n ? {\n [LinkName in keyof RevLinkIndex[EntityName]]: RevLinkIndex[EntityName][LinkName] extends LinkDef<\n Entities,\n any,\n any,\n infer Cardinality,\n infer RelatedEntityName,\n any,\n any\n >\n ? {\n entityName: RelatedEntityName;\n cardinality: Cardinality;\n }\n : never;\n }\n : {};\n\ntype LinksIndexedByEntity<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n Direction extends 'forward' | 'reverse',\n> = {\n [FwdEntity in keyof Entities]: {\n [LinkName in keyof Links as Links[LinkName][Direction]['on'] extends FwdEntity\n ? Links[LinkName][Direction]['label']\n : never]: Links[LinkName] extends LinkDef<\n Entities,\n infer FwdEntity,\n infer FwdAttr,\n infer FwdCardinality,\n infer RevEntity,\n infer RevAttr,\n infer RevCardinality\n >\n ? LinkDef<\n Entities,\n FwdEntity,\n FwdAttr,\n FwdCardinality,\n RevEntity,\n RevAttr,\n RevCardinality\n >\n : never;\n };\n};\n\ntype RequiredKeys<Attrs extends AttrsDefs> = {\n [K in keyof Attrs]: Attrs[K] extends DataAttrDef<any, infer R, any>\n ? R extends true\n ? K\n : never\n : never;\n}[keyof Attrs];\n\ntype OptionalKeys<Attrs extends AttrsDefs> = {\n [K in keyof Attrs]: Attrs[K] extends DataAttrDef<any, infer R, any>\n ? R extends false\n ? K\n : never\n : never;\n}[keyof Attrs];\n\n/**\n * MappedAttrs:\n * - Required keys => `key: ValueType`\n * - Optional keys => `key?: ValueType`\n */\ntype MappedAttrs<\n Attrs extends AttrsDefs,\n UseDates extends boolean | undefined,\n> = {\n [K in RequiredKeys<Attrs>]: Attrs[K] extends DataAttrDef<infer V, any, any>\n ? V extends Date\n ? UseDates extends true\n ? V\n : string | number\n : V\n : never;\n} & {\n [K in OptionalKeys<Attrs>]?: Attrs[K] extends DataAttrDef<infer V, any, any>\n ? V extends Date\n ? UseDates extends true\n ? V\n : string | number\n : V\n : never;\n};\n\nexport type ResolveEntityAttrs<\n EDef extends EntityDef<any, any, any>,\n UseDates extends boolean | undefined = false,\n ResolvedAttrs = MappedAttrs<EDef['attrs'], UseDates>,\n> =\n EDef extends EntityDef<any, any, infer AsType>\n ? AsType extends void\n ? ResolvedAttrs\n : Omit<ResolvedAttrs, keyof AsType> & AsType\n : ResolvedAttrs;\n\nexport type ResolveAttrs<\n Entities extends EntitiesDef,\n EntityName extends keyof Entities,\n UseDates extends boolean,\n> = ResolveEntityAttrs<Entities[EntityName], UseDates>;\n\nexport type RoomsFromDef<RDef extends RoomsDef> = {\n [RoomName in keyof RDef]: {\n presence: Expand<ResolveEntityAttrs<RDef[RoomName]['presence']>>;\n topics: {\n [TopicName in keyof RDef[RoomName]['topics']]: Expand<\n ResolveEntityAttrs<NonNullable<RDef[RoomName]['topics']>[TopicName]>\n >;\n };\n };\n};\n\nexport type RoomsOf<S> =\n S extends InstantSchemaDef<any, any, infer RDef> ? RoomsFromDef<RDef> : never;\n\nexport type PresenceOf<\n S,\n RoomType extends keyof RoomsOf<S>,\n> = RoomsOf<S>[RoomType] extends { presence: infer P } ? P : {};\n\nexport type TopicsOf<\n S,\n RoomType extends keyof RoomsOf<S>,\n> = RoomsOf<S>[RoomType] extends { topics: infer T } ? T : {};\n\nexport type TopicOf<\n S,\n RoomType extends keyof RoomsOf<S>,\n TopicType extends keyof TopicsOf<S, RoomType>,\n> = TopicsOf<S, RoomType>[TopicType];\n\ninterface RoomDef {\n presence: EntityDef<any, any, any>;\n topics?: {\n [TopicName: string]: EntityDef<any, any, any>;\n };\n}\n\nexport interface RoomsDef {\n [RoomType: string]: RoomDef;\n}\n\nexport class InstantSchemaDef<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n Rooms extends RoomsDef,\n> implements IContainEntitiesAndLinks<Entities, Links>\n{\n constructor(\n public entities: Entities,\n public links: Links,\n public rooms: Rooms,\n ) {}\n\n /**\n * @deprecated\n * `withRoomSchema` is deprecated. Define your schema in `rooms` directly:\n *\n * @example\n * // Before:\n * const schema = i.schema({\n * // ...\n * }).withRoomSchema<RoomSchema>()\n *\n * // After\n * const schema = i.schema({\n * rooms: {\n * // ...\n * }\n * })\n *\n * @see https://instantdb.com/docs/presence-and-topics#typesafety\n */\n withRoomSchema<_RoomSchema extends RoomSchemaShape>() {\n type RDef = RoomDefFromShape<_RoomSchema>;\n return new InstantSchemaDef<Entities, Links, RDef>(\n this.entities,\n this.links,\n {} as RDef,\n );\n }\n}\n\n/**\n * @deprecated\n * `i.graph` is deprecated. Use `i.schema` instead.\n *\n * @see https://instantdb.com/docs/modeling-data\n */\nexport class InstantGraph<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n RoomSchema extends RoomSchemaShape = {},\n> implements IContainEntitiesAndLinks<Entities, Links>\n{\n constructor(\n public entities: Entities,\n public links: Links,\n ) {}\n\n withRoomSchema<_RoomSchema extends RoomSchemaShape>() {\n return new InstantGraph<Entities, Links, _RoomSchema>(\n this.entities,\n this.links,\n );\n }\n}\n\ntype EntityDefFromRoomSlice<Shape extends { [k: string]: any }> = EntityDef<\n {\n [AttrName in keyof Shape]: DataAttrDef<\n Shape[AttrName],\n Shape[AttrName] extends undefined ? false : true,\n any\n >;\n },\n any,\n void\n>;\n\ntype RoomDefFromShape<RoomSchema extends RoomSchemaShape> = {\n [RoomName in keyof RoomSchema]: {\n presence: EntityDefFromRoomSlice<\n NonNullable<RoomSchema[RoomName]['presence']>\n >;\n topics: {\n [TopicName in keyof RoomSchema[RoomName]['topics']]: EntityDefFromRoomSlice<\n NonNullable<RoomSchema[RoomName]['topics'][TopicName]>\n >;\n };\n };\n};\n\ntype EntityDefFromShape<Shape, K extends keyof Shape> = EntityDef<\n {\n [AttrName in keyof Shape[K]]: DataAttrDef<\n Shape[K][AttrName],\n Shape[K][AttrName] extends undefined ? false : true,\n any\n >;\n },\n {\n [LinkName in keyof Shape]: LinkAttrDef<\n 'many',\n LinkName extends string ? LinkName : string\n >;\n },\n void\n>;\n\n/**\n * If you were using the old `schema` types, you can use this to help you\n * migrate.\n *\n * @example\n * // Before\n * const db = init<Schema, Rooms>({...})\n *\n * // After\n * const db = init<BackwardsCompatibleSchema<Schema, Rooms>>({...})\n */\nexport type BackwardsCompatibleSchema<\n Shape extends { [k: string]: any },\n RoomSchema extends RoomSchemaShape = {},\n> = InstantSchemaDef<\n { [K in keyof Shape]: EntityDefFromShape<Shape, K> },\n UnknownLinks<EntitiesDef>,\n RoomDefFromShape<RoomSchema>\n>;\n\n// ----------\n// InstantUnknownSchema\n\nexport type UnknownEntity = EntityDef<\n {\n id: DataAttrDef<string, true, true>;\n [AttrName: string]: DataAttrDef<any, boolean, boolean>;\n },\n { [LinkName: string]: LinkAttrDef<'many', string> },\n void\n>;\n\nexport type UnknownEntities = {\n [EntityName: string]: UnknownEntity;\n};\n\nexport interface UnknownLinks<Entities extends EntitiesDef> {\n [LinkName: string]: LinkDef<\n Entities,\n string,\n string,\n 'many',\n string,\n string,\n 'many'\n >;\n}\n\nexport interface UnknownRooms {\n [RoomName: string]: {\n presence: EntityDef<any, any, any>;\n topics: {\n [TopicName: string]: EntityDef<any, any, any>;\n };\n };\n}\n\nexport class InstantUnknownSchemaDef extends InstantSchemaDef<\n UnknownEntities,\n UnknownLinks<UnknownEntities>,\n UnknownRooms\n> {}\n\nexport type InstantUnknownSchema = InstantUnknownSchemaDef;\n\nexport type CreateParams<\n Schema extends IContainEntitiesAndLinks<any, any>,\n EntityName extends keyof Schema['entities'],\n> = {\n [AttrName in RequiredKeys<\n Schema['entities'][EntityName]['attrs']\n >]: Schema['entities'][EntityName]['attrs'][AttrName] extends DataAttrDef<\n infer ValueType,\n any,\n any\n >\n ? ValueType extends Date\n ? string | number | Date\n : ValueType\n : never;\n} & {\n [AttrName in OptionalKeys<\n Schema['entities'][EntityName]['attrs']\n >]?: Schema['entities'][EntityName]['attrs'][AttrName] extends DataAttrDef<\n infer ValueType,\n false,\n any\n >\n ? (ValueType extends Date ? string | number | Date : ValueType) | null\n : never;\n};\n\nexport type UpdateParams<\n Schema extends IContainEntitiesAndLinks<any, any>,\n EntityName extends keyof Schema['entities'],\n> = {\n [AttrName in keyof Schema['entities'][EntityName]['attrs']]?: Schema['entities'][EntityName]['attrs'][AttrName] extends DataAttrDef<\n infer ValueType,\n infer IsRequired,\n any\n >\n ? IsRequired extends true\n ? ValueType extends Date\n ? string | number | Date\n : ValueType\n : (ValueType extends Date ? string | number | Date : ValueType) | null\n : never;\n};\n\nexport type UpdateOpts = {\n upsert?: boolean | undefined;\n};\n\nexport type LinkParams<\n Schema extends IContainEntitiesAndLinks<any, any>,\n EntityName extends keyof Schema['entities'],\n> = {\n [LinkName in keyof Schema['entities'][EntityName]['links']]?: Schema['entities'][EntityName]['links'][LinkName] extends LinkAttrDef<\n infer Cardinality,\n any\n >\n ? Cardinality extends 'one'\n ? string\n : string | string[]\n : never;\n};\n\nexport type RuleParams = {\n [key: string]: any;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"schemaTypes.js","sourceRoot":"","sources":["../../src/schemaTypes.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAW;IAOtB,YACS,SAAqB,EACrB,QAAoB,EACpB,SAAoB,EAEpB,SAIH,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;QAR9B,cAAS,GAAT,SAAS,CAAY;QACrB,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAW;QAEpB,WAAM,GAAN,MAAM,CAIwB;QAXhC,aAAQ,GAA4B,EAAE,CAAC;IAY3C,CAAC;IAEJ;;;;OAIG;IACH,cAAc;QACZ,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,KAAwB,EACxB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,KAAK,EACL,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,kCAET,IAAI,CAAC,MAAM,KACd,MAAM,EAAE,IAAI,IAEf,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,kCAEC,IAAI,CAAC,MAAM,KACd,OAAO,EAAE,IAAI,IAEhB,CAAC;IACJ,CAAC;CAQF;AAED,MAAM,OAAO,WAAW;IAItB,YACS,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;IAC5B,CAAC;CACL;AAuBD,MAAM,OAAO,SAAS;IAKpB,YACS,KAAY,EACZ,KAAY;QADZ,UAAK,GAAL,KAAK,CAAO;QACZ,UAAK,GAAL,KAAK,CAAO;IAClB,CAAC;IAEJ,MAAM;QACJ,OAAO,IAAI,SAAS,CAAwB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;CACF;AAmQD,MAAM,OAAO,gBAAgB;IAM3B,YACS,QAAkB,EAClB,KAAY,EACZ,KAAY;QAFZ,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAO;QACZ,UAAK,GAAL,KAAK,CAAO;IAClB,CAAC;IAEJ;;;;;;;;;;;;;;;;;;OAkBG;IACH,cAAc;QAEZ,OAAO,IAAI,gBAAgB,CACzB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,EAAU,CACX,CAAC;IACJ,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAMvB,YACS,QAAkB,EAClB,KAAY;QADZ,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAO;IAClB,CAAC;IAEJ,cAAc;QACZ,OAAO,IAAI,YAAY,CACrB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,CACX,CAAC;IACJ,CAAC;CACF;AAqGD,MAAM,OAAO,uBAAwB,SAAQ,gBAI5C;CAAG","sourcesContent":["import type { RoomSchemaShape } from './presence.ts';\nimport { Expand } from './queryTypes.ts';\n\nexport class DataAttrDef<\n ValueType,\n IsRequired extends RequirementKind,\n IsIndexed extends boolean,\n> {\n public metadata: Record<string, unknown> = {};\n\n constructor(\n public valueType: ValueTypes,\n public required: IsRequired,\n public isIndexed: IsIndexed,\n\n public config: {\n indexed: boolean;\n unique: boolean;\n // clientValidator?: (value: ValueType) => boolean;\n } = { indexed: false, unique: false },\n ) {}\n\n /**\n * @deprecated Only use this temporarily for attributes that you want\n * to treat as required in frontend code but can’t yet mark as required\n * and enforced for backend\n */\n clientRequired() {\n return new DataAttrDef<ValueType, true, IsIndexed>(\n this.valueType,\n false as unknown as true,\n this.isIndexed,\n this.config,\n );\n }\n\n optional() {\n return new DataAttrDef<ValueType, false, IsIndexed>(\n this.valueType,\n false,\n this.isIndexed,\n this.config,\n );\n }\n\n unique() {\n return new DataAttrDef<ValueType, IsRequired, IsIndexed>(\n this.valueType,\n this.required,\n this.isIndexed,\n {\n ...this.config,\n unique: true,\n },\n );\n }\n\n indexed() {\n return new DataAttrDef<ValueType, IsRequired, true>(\n this.valueType,\n this.required,\n true,\n {\n ...this.config,\n indexed: true,\n },\n );\n }\n\n // clientValidate(clientValidator: (value: ValueType) => boolean) {\n // return new DataAttrDef(this.valueType, this.required, {\n // ...this.config,\n // clientValidator,\n // });\n // }\n}\n\nexport class LinkAttrDef<\n Cardinality extends CardinalityKind,\n EntityName extends string,\n> {\n constructor(\n public cardinality: Cardinality,\n public entityName: EntityName,\n ) {}\n}\n\nexport interface IContainEntitiesAndLinks<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n> {\n entities: Entities;\n links: Links;\n}\n\n// ==========\n// base types\n\nexport type ValueTypes = 'string' | 'number' | 'boolean' | 'date' | 'json';\n\nexport type CardinalityKind = 'one' | 'many';\n\n// true - force required\n// false - optional, not required\nexport type RequirementKind = true | false;\n\nexport type AttrsDefs = Record<string, DataAttrDef<any, any, any>>;\n\nexport class EntityDef<\n Attrs extends AttrsDefs,\n Links extends Record<string, LinkAttrDef<any, any>>,\n AsType,\n> {\n constructor(\n public attrs: Attrs,\n public links: Links,\n ) {}\n\n asType<_AsType extends Partial<MappedAttrs<Attrs, boolean>>>() {\n return new EntityDef<Attrs, Links, _AsType>(this.attrs, this.links);\n }\n}\n\nexport type EntityDefFromSchema<\n S extends IContainEntitiesAndLinks<any, any>,\n K extends keyof S['entities'],\n> = {\n [k in keyof S['entities'][K]['attrs']]: S['entities'][K] extends EntityDef<\n any,\n any,\n any\n >\n ? S['entities'][K]['attrs'][k]\n : never;\n};\n\nexport type EntitiesDef = Record<string, EntityDef<any, any, any>>;\n\nexport type LinksDef<Entities extends EntitiesDef> = Record<\n string,\n LinkDef<\n Entities,\n keyof Entities,\n string,\n CardinalityKind,\n keyof Entities,\n string,\n CardinalityKind\n >\n>;\n\nexport type LinkDef<\n Entities extends EntitiesDef,\n FwdEntity extends keyof Entities,\n FwdAttr extends string,\n FwdCardinality extends CardinalityKind,\n RevEntity extends keyof Entities,\n RevAttr extends string,\n RevCardinality extends CardinalityKind,\n> = {\n forward: {\n on: FwdEntity;\n label: FwdAttr;\n has: FwdCardinality;\n required?: RequirementKind;\n onDelete?: 'cascade';\n };\n reverse: {\n on: RevEntity;\n label: RevAttr;\n has: RevCardinality;\n onDelete?: 'cascade';\n };\n};\n\n// ==========\n// derived types\ntype IsEmptyOrIndexSignature<T> = keyof T extends never\n ? true\n : string extends keyof T\n ? true\n : false;\n\nexport type EntitiesWithLinks<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n> = {\n [EntityName in keyof Entities]: EntityDef<\n Entities[EntityName]['attrs'],\n EntityForwardLinksMap<EntityName, Entities, Links> &\n EntityReverseLinksMap<EntityName, Entities, Links>,\n Entities[EntityName] extends EntityDef<any, any, infer O>\n ? O extends void\n ? void\n : O\n : void\n >;\n};\n\ntype EntityForwardLinksMap<\n EntityName extends keyof Entities,\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n LinkIndexFwd = LinksIndexedByEntity<Entities, Links, 'reverse'>,\n> =\n IsEmptyOrIndexSignature<Links> extends true\n ? {}\n : EntityName extends keyof LinkIndexFwd\n ? {\n [LinkName in keyof LinkIndexFwd[EntityName]]: LinkIndexFwd[EntityName][LinkName] extends LinkDef<\n Entities,\n infer RelatedEntityName,\n any,\n any,\n any,\n any,\n infer Cardinality\n >\n ? {\n entityName: RelatedEntityName;\n cardinality: Cardinality;\n }\n : never;\n }\n : {};\n\ntype EntityReverseLinksMap<\n EntityName extends keyof Entities,\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n RevLinkIndex = LinksIndexedByEntity<Entities, Links, 'forward'>,\n> =\n IsEmptyOrIndexSignature<Links> extends true\n ? {}\n : EntityName extends keyof RevLinkIndex\n ? {\n [LinkName in keyof RevLinkIndex[EntityName]]: RevLinkIndex[EntityName][LinkName] extends LinkDef<\n Entities,\n any,\n any,\n infer Cardinality,\n infer RelatedEntityName,\n any,\n any\n >\n ? {\n entityName: RelatedEntityName;\n cardinality: Cardinality;\n }\n : never;\n }\n : {};\n\ntype LinksIndexedByEntity<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n Direction extends 'forward' | 'reverse',\n> = {\n [FwdEntity in keyof Entities]: {\n [LinkName in keyof Links as Links[LinkName][Direction]['on'] extends FwdEntity\n ? Links[LinkName][Direction]['label']\n : never]: Links[LinkName] extends LinkDef<\n Entities,\n infer FwdEntity,\n infer FwdAttr,\n infer FwdCardinality,\n infer RevEntity,\n infer RevAttr,\n infer RevCardinality\n >\n ? LinkDef<\n Entities,\n FwdEntity,\n FwdAttr,\n FwdCardinality,\n RevEntity,\n RevAttr,\n RevCardinality\n >\n : never;\n };\n};\n\ntype RequiredKeys<Attrs extends AttrsDefs> = {\n [K in keyof Attrs]: Attrs[K] extends DataAttrDef<any, infer R, any>\n ? R extends true\n ? K\n : never\n : never;\n}[keyof Attrs];\n\ntype OptionalKeys<Attrs extends AttrsDefs> = {\n [K in keyof Attrs]: Attrs[K] extends DataAttrDef<any, infer R, any>\n ? R extends false\n ? K\n : never\n : never;\n}[keyof Attrs];\n\n/**\n * MappedAttrs:\n * - Required keys => `key: ValueType`\n * - Optional keys => `key?: ValueType`\n */\ntype MappedAttrs<Attrs extends AttrsDefs, UseDates extends boolean> = {\n [K in RequiredKeys<Attrs>]: Attrs[K] extends DataAttrDef<infer V, any, any>\n ? V extends Date\n ? UseDates extends true\n ? V\n : string | number\n : V\n : never;\n} & {\n [K in OptionalKeys<Attrs>]?: Attrs[K] extends DataAttrDef<infer V, any, any>\n ? V extends Date\n ? UseDates extends true\n ? V\n : string | number\n : V\n : never;\n};\n\nexport type ResolveEntityAttrs<\n EDef extends EntityDef<any, any, any>,\n UseDates extends boolean = false,\n ResolvedAttrs = MappedAttrs<EDef['attrs'], UseDates>,\n> =\n EDef extends EntityDef<any, any, infer AsType>\n ? AsType extends void\n ? ResolvedAttrs\n : Omit<ResolvedAttrs, keyof AsType> & AsType\n : ResolvedAttrs;\n\nexport type ResolveAttrs<\n Entities extends EntitiesDef,\n EntityName extends keyof Entities,\n UseDates extends boolean,\n> = ResolveEntityAttrs<Entities[EntityName], UseDates>;\n\nexport type RoomsFromDef<RDef extends RoomsDef> = {\n [RoomName in keyof RDef]: {\n presence: Expand<ResolveEntityAttrs<RDef[RoomName]['presence']>>;\n topics: {\n [TopicName in keyof RDef[RoomName]['topics']]: Expand<\n ResolveEntityAttrs<NonNullable<RDef[RoomName]['topics']>[TopicName]>\n >;\n };\n };\n};\n\nexport type RoomsOf<S> =\n S extends InstantSchemaDef<any, any, infer RDef> ? RoomsFromDef<RDef> : never;\n\nexport type PresenceOf<\n S,\n RoomType extends keyof RoomsOf<S>,\n> = RoomsOf<S>[RoomType] extends { presence: infer P } ? P : {};\n\nexport type TopicsOf<\n S,\n RoomType extends keyof RoomsOf<S>,\n> = RoomsOf<S>[RoomType] extends { topics: infer T } ? T : {};\n\nexport type TopicOf<\n S,\n RoomType extends keyof RoomsOf<S>,\n TopicType extends keyof TopicsOf<S, RoomType>,\n> = TopicsOf<S, RoomType>[TopicType];\n\ninterface RoomDef {\n presence: EntityDef<any, any, any>;\n topics?: {\n [TopicName: string]: EntityDef<any, any, any>;\n };\n}\n\nexport interface RoomsDef {\n [RoomType: string]: RoomDef;\n}\n\nexport class InstantSchemaDef<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n Rooms extends RoomsDef,\n> implements IContainEntitiesAndLinks<Entities, Links>\n{\n constructor(\n public entities: Entities,\n public links: Links,\n public rooms: Rooms,\n ) {}\n\n /**\n * @deprecated\n * `withRoomSchema` is deprecated. Define your schema in `rooms` directly:\n *\n * @example\n * // Before:\n * const schema = i.schema({\n * // ...\n * }).withRoomSchema<RoomSchema>()\n *\n * // After\n * const schema = i.schema({\n * rooms: {\n * // ...\n * }\n * })\n *\n * @see https://instantdb.com/docs/presence-and-topics#typesafety\n */\n withRoomSchema<_RoomSchema extends RoomSchemaShape>() {\n type RDef = RoomDefFromShape<_RoomSchema>;\n return new InstantSchemaDef<Entities, Links, RDef>(\n this.entities,\n this.links,\n {} as RDef,\n );\n }\n}\n\n/**\n * @deprecated\n * `i.graph` is deprecated. Use `i.schema` instead.\n *\n * @see https://instantdb.com/docs/modeling-data\n */\nexport class InstantGraph<\n Entities extends EntitiesDef,\n Links extends LinksDef<Entities>,\n RoomSchema extends RoomSchemaShape = {},\n> implements IContainEntitiesAndLinks<Entities, Links>\n{\n constructor(\n public entities: Entities,\n public links: Links,\n ) {}\n\n withRoomSchema<_RoomSchema extends RoomSchemaShape>() {\n return new InstantGraph<Entities, Links, _RoomSchema>(\n this.entities,\n this.links,\n );\n }\n}\n\ntype EntityDefFromRoomSlice<Shape extends { [k: string]: any }> = EntityDef<\n {\n [AttrName in keyof Shape]: DataAttrDef<\n Shape[AttrName],\n Shape[AttrName] extends undefined ? false : true,\n any\n >;\n },\n any,\n void\n>;\n\ntype RoomDefFromShape<RoomSchema extends RoomSchemaShape> = {\n [RoomName in keyof RoomSchema]: {\n presence: EntityDefFromRoomSlice<\n NonNullable<RoomSchema[RoomName]['presence']>\n >;\n topics: {\n [TopicName in keyof RoomSchema[RoomName]['topics']]: EntityDefFromRoomSlice<\n NonNullable<RoomSchema[RoomName]['topics'][TopicName]>\n >;\n };\n };\n};\n\ntype EntityDefFromShape<Shape, K extends keyof Shape> = EntityDef<\n {\n [AttrName in keyof Shape[K]]: DataAttrDef<\n Shape[K][AttrName],\n Shape[K][AttrName] extends undefined ? false : true,\n any\n >;\n },\n {\n [LinkName in keyof Shape]: LinkAttrDef<\n 'many',\n LinkName extends string ? LinkName : string\n >;\n },\n void\n>;\n\n/**\n * If you were using the old `schema` types, you can use this to help you\n * migrate.\n *\n * @example\n * // Before\n * const db = init<Schema, Rooms>({...})\n *\n * // After\n * const db = init<BackwardsCompatibleSchema<Schema, Rooms>>({...})\n */\nexport type BackwardsCompatibleSchema<\n Shape extends { [k: string]: any },\n RoomSchema extends RoomSchemaShape = {},\n> = InstantSchemaDef<\n { [K in keyof Shape]: EntityDefFromShape<Shape, K> },\n UnknownLinks<EntitiesDef>,\n RoomDefFromShape<RoomSchema>\n>;\n\n// ----------\n// InstantUnknownSchema\n\nexport type UnknownEntity = EntityDef<\n {\n id: DataAttrDef<string, true, true>;\n [AttrName: string]: DataAttrDef<any, boolean, boolean>;\n },\n { [LinkName: string]: LinkAttrDef<'many', string> },\n void\n>;\n\nexport type UnknownEntities = {\n [EntityName: string]: UnknownEntity;\n};\n\nexport interface UnknownLinks<Entities extends EntitiesDef> {\n [LinkName: string]: LinkDef<\n Entities,\n string,\n string,\n 'many',\n string,\n string,\n 'many'\n >;\n}\n\nexport interface UnknownRooms {\n [RoomName: string]: {\n presence: EntityDef<any, any, any>;\n topics: {\n [TopicName: string]: EntityDef<any, any, any>;\n };\n };\n}\n\nexport class InstantUnknownSchemaDef extends InstantSchemaDef<\n UnknownEntities,\n UnknownLinks<UnknownEntities>,\n UnknownRooms\n> {}\n\nexport type InstantUnknownSchema = InstantUnknownSchemaDef;\n\nexport type CreateParams<\n Schema extends IContainEntitiesAndLinks<any, any>,\n EntityName extends keyof Schema['entities'],\n> = {\n [AttrName in RequiredKeys<\n Schema['entities'][EntityName]['attrs']\n >]: Schema['entities'][EntityName]['attrs'][AttrName] extends DataAttrDef<\n infer ValueType,\n any,\n any\n >\n ? ValueType extends Date\n ? string | number | Date\n : ValueType\n : never;\n} & {\n [AttrName in OptionalKeys<\n Schema['entities'][EntityName]['attrs']\n >]?: Schema['entities'][EntityName]['attrs'][AttrName] extends DataAttrDef<\n infer ValueType,\n false,\n any\n >\n ? (ValueType extends Date ? string | number | Date : ValueType) | null\n : never;\n};\n\nexport type UpdateParams<\n Schema extends IContainEntitiesAndLinks<any, any>,\n EntityName extends keyof Schema['entities'],\n> = {\n [AttrName in keyof Schema['entities'][EntityName]['attrs']]?: Schema['entities'][EntityName]['attrs'][AttrName] extends DataAttrDef<\n infer ValueType,\n infer IsRequired,\n any\n >\n ? IsRequired extends true\n ? ValueType extends Date\n ? string | number | Date\n : ValueType\n : (ValueType extends Date ? string | number | Date : ValueType) | null\n : never;\n};\n\nexport type UpdateOpts = {\n upsert?: boolean | undefined;\n};\n\nexport type LinkParams<\n Schema extends IContainEntitiesAndLinks<any, any>,\n EntityName extends keyof Schema['entities'],\n> = {\n [LinkName in keyof Schema['entities'][EntityName]['links']]?: Schema['entities'][EntityName]['links'][LinkName] extends LinkAttrDef<\n infer Cardinality,\n any\n >\n ? Cardinality extends 'one'\n ? string\n : string | string[]\n : never;\n};\n\nexport type RuleParams = {\n [key: string]: any;\n};\n"]}
|
package/dist/standalone/index.js
CHANGED
|
@@ -36,7 +36,7 @@ function P(t) {
|
|
|
36
36
|
}
|
|
37
37
|
return P(String(t));
|
|
38
38
|
}
|
|
39
|
-
const
|
|
39
|
+
const v = {
|
|
40
40
|
Remove: "remove",
|
|
41
41
|
Replace: "replace",
|
|
42
42
|
Add: "add"
|
|
@@ -352,12 +352,12 @@ function tr(t, e, n, r, s) {
|
|
|
352
352
|
if (o.get(u.toString()) && c[u] !== i[u]) {
|
|
353
353
|
const l = e.concat([u]), f = H(l, s);
|
|
354
354
|
n.push({
|
|
355
|
-
op:
|
|
355
|
+
op: v.Replace,
|
|
356
356
|
path: f,
|
|
357
357
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
358
358
|
value: me(c[u])
|
|
359
359
|
}), r.push({
|
|
360
|
-
op:
|
|
360
|
+
op: v.Replace,
|
|
361
361
|
path: f,
|
|
362
362
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
363
363
|
value: me(i[u])
|
|
@@ -366,7 +366,7 @@ function tr(t, e, n, r, s) {
|
|
|
366
366
|
for (let u = i.length; u < c.length; u += 1) {
|
|
367
367
|
const l = e.concat([u]), f = H(l, s);
|
|
368
368
|
n.push({
|
|
369
|
-
op:
|
|
369
|
+
op: v.Add,
|
|
370
370
|
path: f,
|
|
371
371
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
372
372
|
value: me(c[u])
|
|
@@ -377,7 +377,7 @@ function tr(t, e, n, r, s) {
|
|
|
377
377
|
if (u) {
|
|
378
378
|
const l = e.concat(["length"]), f = H(l, s);
|
|
379
379
|
r.push({
|
|
380
|
-
op:
|
|
380
|
+
op: v.Replace,
|
|
381
381
|
path: f,
|
|
382
382
|
value: i.length
|
|
383
383
|
});
|
|
@@ -385,7 +385,7 @@ function tr(t, e, n, r, s) {
|
|
|
385
385
|
for (let l = c.length; i.length < l; l -= 1) {
|
|
386
386
|
const f = e.concat([l - 1]), d = H(f, s);
|
|
387
387
|
r.push({
|
|
388
|
-
op:
|
|
388
|
+
op: v.Remove,
|
|
389
389
|
path: d
|
|
390
390
|
});
|
|
391
391
|
}
|
|
@@ -393,11 +393,11 @@ function tr(t, e, n, r, s) {
|
|
|
393
393
|
}
|
|
394
394
|
function nr({ original: t, copy: e, assignedMap: n }, r, s, i, o) {
|
|
395
395
|
n.forEach((a, c) => {
|
|
396
|
-
const u = Q(t, c), l = me(Q(e, c)), f = a ? ue(t, c) ?
|
|
397
|
-
if (W(u, l) && f ===
|
|
396
|
+
const u = Q(t, c), l = me(Q(e, c)), f = a ? ue(t, c) ? v.Replace : v.Add : v.Remove;
|
|
397
|
+
if (W(u, l) && f === v.Replace)
|
|
398
398
|
return;
|
|
399
399
|
const d = r.concat(c), h = H(d, o);
|
|
400
|
-
s.push(f ===
|
|
400
|
+
s.push(f === v.Remove ? { op: f, path: h } : { op: f, path: h, value: l }), i.push(f === v.Add ? { op: v.Remove, path: h } : f === v.Remove ? { op: v.Add, path: h, value: u } : { op: v.Replace, path: h, value: u });
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
403
|
function rr({ original: t, copy: e }, n, r, s, i) {
|
|
@@ -406,11 +406,11 @@ function rr({ original: t, copy: e }, n, r, s, i) {
|
|
|
406
406
|
if (!e.has(a)) {
|
|
407
407
|
const c = n.concat([o]), u = H(c, i);
|
|
408
408
|
r.push({
|
|
409
|
-
op:
|
|
409
|
+
op: v.Remove,
|
|
410
410
|
path: u,
|
|
411
411
|
value: a
|
|
412
412
|
}), s.unshift({
|
|
413
|
-
op:
|
|
413
|
+
op: v.Add,
|
|
414
414
|
path: u,
|
|
415
415
|
value: a
|
|
416
416
|
});
|
|
@@ -420,11 +420,11 @@ function rr({ original: t, copy: e }, n, r, s, i) {
|
|
|
420
420
|
if (!t.has(a)) {
|
|
421
421
|
const c = n.concat([o]), u = H(c, i);
|
|
422
422
|
r.push({
|
|
423
|
-
op:
|
|
423
|
+
op: v.Add,
|
|
424
424
|
path: u,
|
|
425
425
|
value: a
|
|
426
426
|
}), s.unshift({
|
|
427
|
-
op:
|
|
427
|
+
op: v.Remove,
|
|
428
428
|
path: u,
|
|
429
429
|
value: a
|
|
430
430
|
});
|
|
@@ -444,7 +444,7 @@ function de(t, e, n, r) {
|
|
|
444
444
|
return rr(t, e, n, r, s);
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
const
|
|
447
|
+
const Ae = (t, e, n = !1) => {
|
|
448
448
|
if (typeof t == "object" && t !== null && (!K(t, e) || n))
|
|
449
449
|
throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
|
|
450
450
|
}, Ve = {
|
|
@@ -482,7 +482,7 @@ const ve = (t, e, n = !1) => {
|
|
|
482
482
|
get(t) {
|
|
483
483
|
var e, n;
|
|
484
484
|
const r = S(this), s = U(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, L)) === L.mutable;
|
|
485
|
-
if (r.options.strict &&
|
|
485
|
+
if (r.options.strict && Ae(s, r.options, i), i || r.finalized || !K(s, r.options) || s !== r.original.get(t))
|
|
486
486
|
return s;
|
|
487
487
|
const o = it.createDraft({
|
|
488
488
|
original: s,
|
|
@@ -528,7 +528,7 @@ const ve = (t, e, n = !1) => {
|
|
|
528
528
|
[Te]() {
|
|
529
529
|
return this.entries();
|
|
530
530
|
}
|
|
531
|
-
}, sr = Reflect.ownKeys(Ve),
|
|
531
|
+
}, sr = Reflect.ownKeys(Ve), At = (t, e, { isValuesIterator: n }) => () => {
|
|
532
532
|
var r, s;
|
|
533
533
|
const i = e.next();
|
|
534
534
|
if (i.done)
|
|
@@ -536,7 +536,7 @@ const ve = (t, e, n = !1) => {
|
|
|
536
536
|
const o = i.value;
|
|
537
537
|
let a = t.setMap.get(o);
|
|
538
538
|
const c = S(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, L)) === L.mutable;
|
|
539
|
-
if (t.options.strict &&
|
|
539
|
+
if (t.options.strict && Ae(o, t.options, u), !u && !c && K(o, t.options) && !t.finalized && t.original.has(o)) {
|
|
540
540
|
const l = it.createDraft({
|
|
541
541
|
original: o,
|
|
542
542
|
parentDraft: t,
|
|
@@ -550,7 +550,7 @@ const ve = (t, e, n = !1) => {
|
|
|
550
550
|
done: !1,
|
|
551
551
|
value: n ? a : [a, a]
|
|
552
552
|
};
|
|
553
|
-
},
|
|
553
|
+
}, ve = {
|
|
554
554
|
get size() {
|
|
555
555
|
return S(this).setMap.size;
|
|
556
556
|
},
|
|
@@ -589,7 +589,7 @@ const ve = (t, e, n = !1) => {
|
|
|
589
589
|
const e = t.setMap.keys();
|
|
590
590
|
return {
|
|
591
591
|
[Symbol.iterator]: () => this.values(),
|
|
592
|
-
next:
|
|
592
|
+
next: At(t, e, { isValuesIterator: !0 })
|
|
593
593
|
};
|
|
594
594
|
},
|
|
595
595
|
entries() {
|
|
@@ -598,7 +598,7 @@ const ve = (t, e, n = !1) => {
|
|
|
598
598
|
const e = t.setMap.keys();
|
|
599
599
|
return {
|
|
600
600
|
[Symbol.iterator]: () => this.entries(),
|
|
601
|
-
next:
|
|
601
|
+
next: At(t, e, {
|
|
602
602
|
isValuesIterator: !1
|
|
603
603
|
})
|
|
604
604
|
};
|
|
@@ -616,7 +616,7 @@ const ve = (t, e, n = !1) => {
|
|
|
616
616
|
t.call(e, r.value, r.value, this), r = n.next();
|
|
617
617
|
}
|
|
618
618
|
};
|
|
619
|
-
Set.prototype.difference && Object.assign(
|
|
619
|
+
Set.prototype.difference && Object.assign(ve, {
|
|
620
620
|
intersection(t) {
|
|
621
621
|
return Set.prototype.intersection.call(new Set(this.values()), t);
|
|
622
622
|
},
|
|
@@ -639,7 +639,7 @@ Set.prototype.difference && Object.assign(Ae, {
|
|
|
639
639
|
return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
|
|
640
640
|
}
|
|
641
641
|
});
|
|
642
|
-
const ir = Reflect.ownKeys(
|
|
642
|
+
const ir = Reflect.ownKeys(ve), an = /* @__PURE__ */ new WeakSet(), cn = {
|
|
643
643
|
get(t, e, n) {
|
|
644
644
|
var r, s;
|
|
645
645
|
const i = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
|
|
@@ -651,7 +651,7 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
|
|
|
651
651
|
if (t.options.mark) {
|
|
652
652
|
const u = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
|
|
653
653
|
if (o = t.options.mark(u, L), o === L.mutable)
|
|
654
|
-
return t.options.strict &&
|
|
654
|
+
return t.options.strict && Ae(u, t.options, !0), u;
|
|
655
655
|
}
|
|
656
656
|
const a = U(t);
|
|
657
657
|
if (a instanceof Map && sr.includes(e)) {
|
|
@@ -663,8 +663,8 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
|
|
|
663
663
|
}
|
|
664
664
|
if (a instanceof Set && ir.includes(e)) {
|
|
665
665
|
if (e === "size")
|
|
666
|
-
return Object.getOwnPropertyDescriptor(
|
|
667
|
-
const u =
|
|
666
|
+
return Object.getOwnPropertyDescriptor(ve, "size").get.call(t.proxy);
|
|
667
|
+
const u = ve[e];
|
|
668
668
|
if (u)
|
|
669
669
|
return u.bind(t.proxy);
|
|
670
670
|
}
|
|
@@ -676,7 +676,7 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
|
|
|
676
676
|
) : void 0;
|
|
677
677
|
}
|
|
678
678
|
const c = a[e];
|
|
679
|
-
if (t.options.strict &&
|
|
679
|
+
if (t.options.strict && Ae(c, t.options), t.finalized || !K(c, t.options))
|
|
680
680
|
return c;
|
|
681
681
|
if (c === Re(t.original, e)) {
|
|
682
682
|
if (j(t), t.copy[e] = ft({
|
|
@@ -783,8 +783,8 @@ function or(t, e, n, r, s) {
|
|
|
783
783
|
const u = c ? e[0] : o ? o.operated ? o.copy : o.original : t;
|
|
784
784
|
return o && Ke(o), s && X(u, u, o == null ? void 0 : o.options.updatedValues), [
|
|
785
785
|
u,
|
|
786
|
-
n && c ? [{ op:
|
|
787
|
-
r && c ? [{ op:
|
|
786
|
+
n && c ? [{ op: v.Replace, path: [], value: e[0] }] : n,
|
|
787
|
+
r && c ? [{ op: v.Replace, path: [], value: a }] : r
|
|
788
788
|
];
|
|
789
789
|
}
|
|
790
790
|
function ar(t, e) {
|
|
@@ -857,7 +857,7 @@ function un(t) {
|
|
|
857
857
|
}
|
|
858
858
|
return s;
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function vt(t) {
|
|
861
861
|
if (!Y(t))
|
|
862
862
|
throw new Error(`current() is only used for Draft, parameter: ${t}`);
|
|
863
863
|
return un(t);
|
|
@@ -873,7 +873,7 @@ const cr = (t) => function e(n, r, s) {
|
|
|
873
873
|
if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
|
|
874
874
|
throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
|
|
875
875
|
l = Object.assign(Object.assign({}, t), l);
|
|
876
|
-
const f = Y(c) ?
|
|
876
|
+
const f = Y(c) ? vt(c) : c, d = Array.isArray(l.mark) ? (m, M) => {
|
|
877
877
|
for (const I of l.mark) {
|
|
878
878
|
if (typeof I != "function")
|
|
879
879
|
throw new Error(`Invalid mark: ${I}, 'mark' should be a function.`);
|
|
@@ -901,7 +901,7 @@ const cr = (t) => function e(n, r, s) {
|
|
|
901
901
|
} catch (m) {
|
|
902
902
|
throw Ke(S(y)), m;
|
|
903
903
|
}
|
|
904
|
-
const
|
|
904
|
+
const A = (m) => {
|
|
905
905
|
const M = S(y);
|
|
906
906
|
if (!Y(m)) {
|
|
907
907
|
if (m !== void 0 && !W(m, y) && (M != null && M.operated))
|
|
@@ -924,13 +924,13 @@ const cr = (t) => function e(n, r, s) {
|
|
|
924
924
|
if (_ === I.options) {
|
|
925
925
|
if (I.operated)
|
|
926
926
|
throw new Error("Cannot return a modified child draft.");
|
|
927
|
-
return g([
|
|
927
|
+
return g([vt(m)]);
|
|
928
928
|
}
|
|
929
929
|
return g([m]);
|
|
930
930
|
};
|
|
931
|
-
return T instanceof Promise ? T.then(
|
|
931
|
+
return T instanceof Promise ? T.then(A, (m) => {
|
|
932
932
|
throw Ke(S(y)), m;
|
|
933
|
-
}) :
|
|
933
|
+
}) : A(T);
|
|
934
934
|
}, ke = cr();
|
|
935
935
|
Object.prototype.constructor.toString();
|
|
936
936
|
function ln(t, e) {
|
|
@@ -1281,7 +1281,7 @@ function Or(t) {
|
|
|
1281
1281
|
const [n] = e, r = fr[n], s = new Date(t.replace(Ct, "Z"));
|
|
1282
1282
|
return new Date(s.getTime() - r * 1e3);
|
|
1283
1283
|
}
|
|
1284
|
-
const
|
|
1284
|
+
const Ar = [
|
|
1285
1285
|
yr,
|
|
1286
1286
|
_r,
|
|
1287
1287
|
wr,
|
|
@@ -1294,7 +1294,7 @@ const vr = [
|
|
|
1294
1294
|
Sr,
|
|
1295
1295
|
Or
|
|
1296
1296
|
];
|
|
1297
|
-
function
|
|
1297
|
+
function vr(t, e) {
|
|
1298
1298
|
try {
|
|
1299
1299
|
const n = t(e);
|
|
1300
1300
|
return n instanceof Date && !isNaN(n.getTime()) ? n : null;
|
|
@@ -1303,8 +1303,8 @@ function Ar(t, e) {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
1305
|
function Qe(t) {
|
|
1306
|
-
for (const e of
|
|
1307
|
-
const n =
|
|
1306
|
+
for (const e of Ar) {
|
|
1307
|
+
const n = vr(e, t);
|
|
1308
1308
|
if (n)
|
|
1309
1309
|
return n;
|
|
1310
1310
|
}
|
|
@@ -1743,7 +1743,7 @@ function Kr(t) {
|
|
|
1743
1743
|
function qr(t, e, n) {
|
|
1744
1744
|
if (n.hasOwnProperty(t)) {
|
|
1745
1745
|
const r = n[t];
|
|
1746
|
-
return
|
|
1746
|
+
return An(r, e, n);
|
|
1747
1747
|
}
|
|
1748
1748
|
return { ...n, [t]: e };
|
|
1749
1749
|
}
|
|
@@ -1772,13 +1772,13 @@ function Wr(t) {
|
|
|
1772
1772
|
return !0;
|
|
1773
1773
|
return !1;
|
|
1774
1774
|
}
|
|
1775
|
-
function
|
|
1775
|
+
function An(t, e, n) {
|
|
1776
1776
|
return n ? typeof t == "object" ? Wr(t) ? n : null : zr(t)(t, e, n) : null;
|
|
1777
1777
|
}
|
|
1778
1778
|
function Qr(t, e, n) {
|
|
1779
1779
|
return t.reduce((r, s, i) => {
|
|
1780
1780
|
const o = e[i];
|
|
1781
|
-
return
|
|
1781
|
+
return An(s, o, r);
|
|
1782
1782
|
}, n);
|
|
1783
1783
|
}
|
|
1784
1784
|
function Gr(t, e, n) {
|
|
@@ -1894,7 +1894,7 @@ function ls(t, e, n, r) {
|
|
|
1894
1894
|
function fs(t, e, n) {
|
|
1895
1895
|
return t.map((r) => r === e ? n : r);
|
|
1896
1896
|
}
|
|
1897
|
-
function
|
|
1897
|
+
function vn(t, e, n, r, s) {
|
|
1898
1898
|
const i = G(e, n, s), o = Sn(e, n, s), a = i || o;
|
|
1899
1899
|
if (!a)
|
|
1900
1900
|
throw new ne(`Could not find attr for ${[n, s]}`);
|
|
@@ -2015,7 +2015,7 @@ function hs(t, e, n, r, s, i) {
|
|
|
2015
2015
|
function ps(t, e, n, r, s) {
|
|
2016
2016
|
const [i, o, a] = s.reduce(
|
|
2017
2017
|
(c, u) => {
|
|
2018
|
-
const [l, f, d] = c, [h, p, b] =
|
|
2018
|
+
const [l, f, d] = c, [h, p, b] = vn(
|
|
2019
2019
|
t,
|
|
2020
2020
|
e,
|
|
2021
2021
|
l,
|
|
@@ -2128,7 +2128,7 @@ function ms(t, e, n) {
|
|
|
2128
2128
|
return [t(e, n), t("time", n)];
|
|
2129
2129
|
}
|
|
2130
2130
|
function Ss(t, e, n, r, s, i) {
|
|
2131
|
-
const [o, a, c, u, l] =
|
|
2131
|
+
const [o, a, c, u, l] = vn(
|
|
2132
2132
|
t,
|
|
2133
2133
|
e,
|
|
2134
2134
|
n,
|
|
@@ -2151,12 +2151,12 @@ function Os(t, e, { etype: n, level: r, form: s }, i) {
|
|
|
2151
2151
|
r,
|
|
2152
2152
|
d,
|
|
2153
2153
|
c
|
|
2154
|
-
),
|
|
2154
|
+
), A = Cn(e, {
|
|
2155
2155
|
etype: y,
|
|
2156
2156
|
level: g,
|
|
2157
2157
|
form: s[d],
|
|
2158
2158
|
join: T
|
|
2159
|
-
}), m = h ?
|
|
2159
|
+
}), m = h ? A[0] : A;
|
|
2160
2160
|
return { [d]: m };
|
|
2161
2161
|
} catch (y) {
|
|
2162
2162
|
if (y instanceof ne)
|
|
@@ -2168,11 +2168,11 @@ function Os(t, e, { etype: n, level: r, form: s }, i) {
|
|
|
2168
2168
|
}, u);
|
|
2169
2169
|
}) : Object.values(i);
|
|
2170
2170
|
}
|
|
2171
|
-
function
|
|
2171
|
+
function As(t, e, n) {
|
|
2172
2172
|
return n === "string" ? as(t, e) : t > e ? 1 : -1;
|
|
2173
2173
|
}
|
|
2174
2174
|
function ce(t, e, n, r, s) {
|
|
2175
|
-
return e === r || e == null && r == null ? ss(t, n) : r == null ? 1 : e == null ? -1 :
|
|
2175
|
+
return e === r || e == null && r == null ? ss(t, n) : r == null ? 1 : e == null ? -1 : As(e, r, s);
|
|
2176
2176
|
}
|
|
2177
2177
|
function Ee([t, e], [n, r], s) {
|
|
2178
2178
|
return ce(t, e, n, r, s);
|
|
@@ -2180,7 +2180,7 @@ function Ee([t, e], [n, r], s) {
|
|
|
2180
2180
|
function Je(t) {
|
|
2181
2181
|
return t == null ? t : new Date(t).getTime();
|
|
2182
2182
|
}
|
|
2183
|
-
function
|
|
2183
|
+
function vs(t, e, n, r) {
|
|
2184
2184
|
var p;
|
|
2185
2185
|
const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
|
|
2186
2186
|
if (((p = e["forward-identity"]) == null ? void 0 : p[2]) === "id")
|
|
@@ -2225,8 +2225,8 @@ function Is(t, { etype: e, pageInfo: n, dq: r, form: s }) {
|
|
|
2225
2225
|
if (l && ((p = l == null ? void 0 : l["forward-identity"]) == null ? void 0 : p[2]) !== "id") {
|
|
2226
2226
|
const b = l["checked-data-type"] === "date", _ = l.id;
|
|
2227
2227
|
c = c.map(([y]) => {
|
|
2228
|
-
var T,
|
|
2229
|
-
let g = (I = (M = (m = (
|
|
2228
|
+
var T, A, m, M, I;
|
|
2229
|
+
let g = (I = (M = (m = (A = (T = t.eav.get(y)) == null ? void 0 : T.get(_)) == null ? void 0 : A.values()) == null ? void 0 : m.next()) == null ? void 0 : M.value) == null ? void 0 : I[2];
|
|
2230
2230
|
return b && (g = Je(g)), [y, g];
|
|
2231
2231
|
});
|
|
2232
2232
|
}
|
|
@@ -2241,7 +2241,7 @@ function Is(t, { etype: e, pageInfo: n, dq: r, form: s }) {
|
|
|
2241
2241
|
const d = Ms(t, e, r);
|
|
2242
2242
|
for (const b of c) {
|
|
2243
2243
|
const [_] = b;
|
|
2244
|
-
if (f[_] || !o && u && l &&
|
|
2244
|
+
if (f[_] || !o && u && l && vs(u, l, a, b))
|
|
2245
2245
|
continue;
|
|
2246
2246
|
const y = Ur(t, d, _);
|
|
2247
2247
|
y && (f[_] = y);
|
|
@@ -3368,7 +3368,7 @@ async function Oi({
|
|
|
3368
3368
|
body: r
|
|
3369
3369
|
});
|
|
3370
3370
|
}
|
|
3371
|
-
async function
|
|
3371
|
+
async function Ai({
|
|
3372
3372
|
apiURI: t,
|
|
3373
3373
|
appId: e,
|
|
3374
3374
|
path: n,
|
|
@@ -3386,7 +3386,7 @@ async function vi({
|
|
|
3386
3386
|
);
|
|
3387
3387
|
return s;
|
|
3388
3388
|
}
|
|
3389
|
-
async function
|
|
3389
|
+
async function vi({
|
|
3390
3390
|
apiURI: t,
|
|
3391
3391
|
appId: e,
|
|
3392
3392
|
fileName: n,
|
|
@@ -3510,7 +3510,7 @@ function Vt(t) {
|
|
|
3510
3510
|
}, e;
|
|
3511
3511
|
}, {});
|
|
3512
3512
|
}
|
|
3513
|
-
const Fn = "v0.22.
|
|
3513
|
+
const Fn = "v0.22.76";
|
|
3514
3514
|
function Ii(t, e) {
|
|
3515
3515
|
return {
|
|
3516
3516
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
@@ -4100,22 +4100,29 @@ class Ni {
|
|
|
4100
4100
|
this.initParams || this.handleError();
|
|
4101
4101
|
}, 1e4), this.conn.onmessage = (r) => {
|
|
4102
4102
|
const s = JSON.parse(r.data);
|
|
4103
|
-
if (s
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
}, this.onopen && this.onopen({ target: this }), clearTimeout(this.sseInitTimeout);
|
|
4109
|
-
return;
|
|
4110
|
-
}
|
|
4111
|
-
this.onmessage && this.onmessage({
|
|
4112
|
-
target: this,
|
|
4113
|
-
message: s
|
|
4114
|
-
});
|
|
4103
|
+
if (Array.isArray(s))
|
|
4104
|
+
for (const i of s)
|
|
4105
|
+
this.handleMessage(i);
|
|
4106
|
+
else
|
|
4107
|
+
this.handleMessage(s);
|
|
4115
4108
|
}, this.conn.onerror = (r) => {
|
|
4116
4109
|
this.handleError();
|
|
4117
4110
|
};
|
|
4118
4111
|
}
|
|
4112
|
+
handleMessage(e) {
|
|
4113
|
+
if (e.op === "sse-init") {
|
|
4114
|
+
this.initParams = {
|
|
4115
|
+
machineId: e["machine-id"],
|
|
4116
|
+
sessionId: e["session-id"],
|
|
4117
|
+
sseToken: e["sse-token"]
|
|
4118
|
+
}, this.onopen && this.onopen({ target: this }), clearTimeout(this.sseInitTimeout);
|
|
4119
|
+
return;
|
|
4120
|
+
}
|
|
4121
|
+
this.onmessage && this.onmessage({
|
|
4122
|
+
target: this,
|
|
4123
|
+
message: e
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4119
4126
|
// Runs the onerror and closes the connection
|
|
4120
4127
|
handleError() {
|
|
4121
4128
|
try {
|
|
@@ -4511,12 +4518,12 @@ class Bi {
|
|
|
4511
4518
|
const T = f[g];
|
|
4512
4519
|
if (Cr(T.store, _)) {
|
|
4513
4520
|
Yt(T.store, y);
|
|
4514
|
-
const
|
|
4515
|
-
|
|
4521
|
+
const A = Fe(s, T.store), m = Vi(T.store, y)[_];
|
|
4522
|
+
A ? (d.push({
|
|
4516
4523
|
oldEntity: T.entity,
|
|
4517
|
-
newEntity:
|
|
4524
|
+
newEntity: A,
|
|
4518
4525
|
changedFields: m || {}
|
|
4519
|
-
}), T.entity =
|
|
4526
|
+
}), T.entity = A) : c.push(g), delete u[_];
|
|
4520
4527
|
continue e;
|
|
4521
4528
|
}
|
|
4522
4529
|
}
|
|
@@ -4843,7 +4850,11 @@ class oo {
|
|
|
4843
4850
|
);
|
|
4844
4851
|
return;
|
|
4845
4852
|
}
|
|
4846
|
-
!this._wsOk && n.type === "ws" && (this._wsOk = !0), this._transportType = "ws",
|
|
4853
|
+
if (!this._wsOk && n.type === "ws" && (this._wsOk = !0), this._transportType = "ws", Array.isArray(e.message))
|
|
4854
|
+
for (const s of e.message)
|
|
4855
|
+
this._handleReceive(n.id, s);
|
|
4856
|
+
else
|
|
4857
|
+
this._handleReceive(n.id, e.message);
|
|
4847
4858
|
});
|
|
4848
4859
|
w(this, "_transportOnError", (e) => {
|
|
4849
4860
|
const n = e.target;
|
|
@@ -5118,7 +5129,7 @@ class oo {
|
|
|
5118
5129
|
});
|
|
5119
5130
|
const _ = Xt(b.entries()), y = d.map((g) => {
|
|
5120
5131
|
var gt, wt, Tt, mt;
|
|
5121
|
-
const T = g["instaql-query"],
|
|
5132
|
+
const T = g["instaql-query"], A = g["instaql-result"], m = P(T), M = zt(A), I = Oe(
|
|
5122
5133
|
this.attrs,
|
|
5123
5134
|
M,
|
|
5124
5135
|
r,
|
|
@@ -5128,16 +5139,16 @@ class oo {
|
|
|
5128
5139
|
I,
|
|
5129
5140
|
_,
|
|
5130
5141
|
p
|
|
5131
|
-
), De = (wt = (gt =
|
|
5142
|
+
), De = (wt = (gt = A == null ? void 0 : A[0]) == null ? void 0 : gt.data) == null ? void 0 : wt["page-info"], Gn = (mt = (Tt = A == null ? void 0 : A[0]) == null ? void 0 : Tt.data) == null ? void 0 : mt.aggregate;
|
|
5132
5143
|
return { q: T, hash: m, store: B, pageInfo: De, aggregate: Gn };
|
|
5133
5144
|
});
|
|
5134
|
-
y.forEach(({ hash: g, q: T, store:
|
|
5145
|
+
y.forEach(({ hash: g, q: T, store: A, pageInfo: m, aggregate: M }) => {
|
|
5135
5146
|
this.querySubs.updateInPlace((I) => {
|
|
5136
5147
|
if (!I[g]) {
|
|
5137
5148
|
this._log.error("Missing value in querySubs", { hash: g, q: T });
|
|
5138
5149
|
return;
|
|
5139
5150
|
}
|
|
5140
|
-
I[g].result = { store:
|
|
5151
|
+
I[g].result = { store: A, pageInfo: m, aggregate: M, processedTxId: p };
|
|
5141
5152
|
});
|
|
5142
5153
|
}), this._cleanupPendingMutationsQueries(), y.forEach(({ hash: g }) => {
|
|
5143
5154
|
this.notifyOne(g);
|
|
@@ -6038,7 +6049,7 @@ class oo {
|
|
|
6038
6049
|
async deleteFile(e) {
|
|
6039
6050
|
var i;
|
|
6040
6051
|
const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
|
|
6041
|
-
return await
|
|
6052
|
+
return await Ai({
|
|
6042
6053
|
apiURI: this.config.apiURI,
|
|
6043
6054
|
appId: this.config.appId,
|
|
6044
6055
|
path: e,
|
|
@@ -6049,7 +6060,7 @@ class oo {
|
|
|
6049
6060
|
// ---------------------------------
|
|
6050
6061
|
async upload(e, n) {
|
|
6051
6062
|
var c;
|
|
6052
|
-
const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await
|
|
6063
|
+
const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await vi({
|
|
6053
6064
|
apiURI: this.config.apiURI,
|
|
6054
6065
|
appId: this.config.appId,
|
|
6055
6066
|
fileName: i,
|
|
@@ -6255,11 +6266,11 @@ function Oo(t) {
|
|
|
6255
6266
|
}
|
|
6256
6267
|
return { element: e, isVisible: n };
|
|
6257
6268
|
}
|
|
6258
|
-
const
|
|
6269
|
+
const Ao = {
|
|
6259
6270
|
apiURI: "https://api.instantdb.com",
|
|
6260
6271
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
6261
6272
|
};
|
|
6262
|
-
function
|
|
6273
|
+
function vo() {
|
|
6263
6274
|
return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
|
|
6264
6275
|
}
|
|
6265
6276
|
function ko() {
|
|
@@ -6269,7 +6280,7 @@ function rt(t) {
|
|
|
6269
6280
|
const e = t.__adminToken;
|
|
6270
6281
|
return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
|
|
6271
6282
|
}
|
|
6272
|
-
const st = ko(), en =
|
|
6283
|
+
const st = ko(), en = vo();
|
|
6273
6284
|
class Eo {
|
|
6274
6285
|
constructor(e) {
|
|
6275
6286
|
this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
|
|
@@ -6472,23 +6483,24 @@ function Io(t, e) {
|
|
|
6472
6483
|
return tn(t._reactor.config.schema) !== tn(e);
|
|
6473
6484
|
}
|
|
6474
6485
|
function Po(t, e, n, r, s) {
|
|
6475
|
-
const i =
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6486
|
+
const i = {
|
|
6487
|
+
...t,
|
|
6488
|
+
useDateObjects: t.useDateObjects ?? !1
|
|
6489
|
+
}, o = st[rt(i)];
|
|
6490
|
+
if (o)
|
|
6491
|
+
return Io(o, i.schema) && o._reactor.updateSchema(i.schema), o;
|
|
6492
|
+
const a = new oo(
|
|
6479
6493
|
{
|
|
6480
|
-
...
|
|
6481
|
-
...
|
|
6482
|
-
cardinalityInference: !!
|
|
6494
|
+
...Ao,
|
|
6495
|
+
...i,
|
|
6496
|
+
cardinalityInference: !!i.schema
|
|
6483
6497
|
},
|
|
6484
6498
|
e || Dn,
|
|
6485
6499
|
n || Rn,
|
|
6486
6500
|
{ ...r || {}, "@instantdb/core": Fn },
|
|
6487
6501
|
s
|
|
6488
|
-
),
|
|
6489
|
-
|
|
6490
|
-
);
|
|
6491
|
-
return st[rt(t)] = a, jo(t.appId, t.devtool), a;
|
|
6502
|
+
), c = new Mo(a);
|
|
6503
|
+
return st[rt(i)] = c, jo(i.appId, i.devtool), c;
|
|
6492
6504
|
}
|
|
6493
6505
|
function jo(t, e) {
|
|
6494
6506
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|