@fluidframework/aqueduct 0.52.1 → 0.53.0-46105
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/data-object-factories/dataObjectFactory.d.ts +21 -4
- package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/dataObjectFactory.js +18 -4
- package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.d.ts +30 -13
- package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.js +18 -4
- package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/dist/data-objects/dataObject.d.ts +25 -5
- package/dist/data-objects/dataObject.d.ts.map +1 -1
- package/dist/data-objects/dataObject.js +21 -5
- package/dist/data-objects/dataObject.js.map +1 -1
- package/dist/data-objects/index.d.ts +3 -2
- package/dist/data-objects/index.d.ts.map +1 -1
- package/dist/data-objects/index.js +3 -1
- package/dist/data-objects/index.js.map +1 -1
- package/dist/data-objects/pureDataObject.d.ts +26 -15
- package/dist/data-objects/pureDataObject.d.ts.map +1 -1
- package/dist/data-objects/pureDataObject.js +18 -5
- package/dist/data-objects/pureDataObject.js.map +1 -1
- package/dist/data-objects/types.d.ts +38 -0
- package/dist/data-objects/types.d.ts.map +1 -0
- package/dist/data-objects/types.js +7 -0
- package/dist/data-objects/types.js.map +1 -0
- package/dist/test/tsconfig.tsbuildinfo +16 -14
- package/lib/data-object-factories/dataObjectFactory.js +16 -3
- package/lib/data-object-factories/dataObjectFactory.js.map +1 -1
- package/lib/data-object-factories/pureDataObjectFactory.js +16 -3
- package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/lib/data-objects/dataObject.js +19 -4
- package/lib/data-objects/dataObject.js.map +1 -1
- package/lib/data-objects/index.js +2 -2
- package/lib/data-objects/index.js.map +1 -1
- package/lib/data-objects/pureDataObject.js +16 -4
- package/lib/data-objects/pureDataObject.js.map +1 -1
- package/lib/data-objects/types.js +6 -0
- package/lib/data-objects/types.js.map +1 -0
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAWvE;;;;;;;;GAQG;AACH,wDAAwD;AACxD,MAAM,OAAgB,cAClB,SAAQ,cAAiB;IAgDzB,YAAmB,KAA6B;QAC5C,KAAK,EAAE,CAAC;QA9CJ,cAAS,GAAG,KAAK,CAAC;QA+CtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QAEjC,MAAM,CAAE,IAAI,CAAC,OAAe,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC7G,IAAI,CAAC,OAAe,CAAC,WAAW,GAAG,IAAI,CAAC;QAEzC,8GAA8G;QAC9G,4GAA4G;QAC5G,yBAAyB;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAEvF,2BAA2B;QAC3B,IAAI,CAAC,OAAO,CAA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,GAAG,CAAC,CAAM,CAAC;SACnF;IACL,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,yBAAyB,CAAyB,EAAU;QACxE,OAAO,mBAAmB,CAAI,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACjF,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,UAAU,CAAuC,EAAU;QACvE,OAAO,mBAAmB,CAAI,IAAI,oBAAoB,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACzG,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAoB,CAAC;IAElD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAS,IAAmB,CAAC;IAEnE;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAoB,CAAC;IAE7D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAoB,CAAC;IAEnD;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IFluidObject,\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { AsyncFluidObjectProvider, FluidObjectKey } from \"@fluidframework/synthesize\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport interface IDataObjectProps<O = object, S = undefined> {\n readonly runtime: IFluidDataStoreRuntime;\n readonly context: IFluidDataStoreContext;\n // eslint-disable-next-line @typescript-eslint/ban-types\n readonly providers: AsyncFluidObjectProvider<FluidObjectKey<O>, FluidObjectKey<object>>;\n readonly initProps?: S;\n}\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport abstract class PureDataObject<O extends IFluidObject = object, S = undefined, E extends IEvent = IEvent>\n extends EventForwarder<E>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle, IFluidObject {\n private readonly innerHandle: IFluidHandle<this>;\n private _disposed = false;\n\n /**\n * This is your FluidDataStoreRuntime object\n */\n protected readonly runtime: IFluidDataStoreRuntime;\n\n /**\n * This context is used to talk up to the ContainerRuntime\n */\n protected readonly context: IFluidDataStoreContext;\n\n /**\n * Providers are IFluidObject keyed objects that provide back\n * a promise to the corresponding IFluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set IFluidObject interfaces in the generic O type for your data store\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n protected readonly providers: AsyncFluidObjectProvider<FluidObjectKey<O>, FluidObjectKey<object>>;\n\n protected initProps?: S;\n\n protected initializeP: Promise<void> | undefined;\n\n public get disposed() { return this._disposed; }\n\n public get id() { return this.runtime.id; }\n public get IFluidRouter() { return this; }\n public get IFluidLoadable() { return this; }\n public get IFluidHandle() { return this.innerHandle; }\n\n /**\n * Handle to a data store\n */\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n\n public static async getDataObject(runtime: IFluidDataStoreRuntime) {\n const obj = (runtime as any)._dataObject as PureDataObject;\n assert(obj !== undefined, 0x0bc /* \"Runtime has no DataObject!\" */);\n await obj.finishInitialization(true);\n return obj;\n }\n\n public constructor(props: IDataObjectProps<O, S>) {\n super();\n this.runtime = props.runtime;\n this.context = props.context;\n this.providers = props.providers;\n this.initProps = props.initProps;\n\n assert((this.runtime as any)._dataObject === undefined, 0x0bd /* \"Object runtime already has DataObject!\" */);\n (this.runtime as any)._dataObject = this;\n\n // Create a FluidObjectHandle with empty string as `path`. This is because reaching this PureDataObject is the\n // same as reaching its routeContext (FluidDataStoreRuntime) so there is so the relative path to it from the\n // routeContext is empty.\n this.innerHandle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n\n // Container event handlers\n this.runtime.once(\"dispose\", () => {\n this._disposed = true;\n this.dispose();\n });\n }\n\n // #region IFluidRouter\n\n /**\n * Return this object if someone requests it directly\n * We will return this object in two scenarios:\n * 1. the request url is a \"/\"\n * 2. the request url is empty\n */\n public async request(req: IRequest): Promise<IResponse> {\n return defaultFluidObjectRequestHandler(this, req);\n }\n\n // #endregion IFluidRouter\n\n // #region IFluidLoadable\n\n // #endregion IFluidLoadable\n\n /**\n * Call this API to ensure PureDataObject is fully initialized\n * initialization happens on demand, only on as-needed bases.\n * In most cases you should allow factory/object to decide when to finish initialization.\n * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n * and need fully initialized object, then you can call this API to ensure object is fully initialized.\n */\n public async finishInitialization(existing: boolean): Promise<void> {\n if (this.initializeP !== undefined) {\n return this.initializeP;\n }\n this.initializeP = this.initializeInternal(existing);\n return this.initializeP;\n }\n\n /**\n * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n * generally not be done.\n *\n * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n * responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n await this.preInitialize();\n if (existing) {\n assert(this.initProps === undefined,\n 0x0be /* \"Trying to initialize from existing while initProps is set!\" */);\n await this.initializingFromExisting();\n } else {\n await this.initializingFirstTime(this.context.createProps as S ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retreive Fluid object using the handle get or the older requestFluidObject_UNSAFE call to fetch by ID\n *\n * @param key - key that object (handle/id) is stored with in the directory\n * @param directory - directory containing the object\n * @param getObjectFromDirectory - optional callback for fetching object from the directory, allows users to\n * define custom types/getters for object retrieval\n */\n public async getFluidObjectFromDirectory<T extends IFluidObject & FluidObject & IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => string | IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleOrId = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n if (typeof handleOrId === \"string\") {\n // For backwards compatibility with older stored IDs\n // We update the storage with the handle so that this code path is less and less trafficked\n const fluidObject = await this.requestFluidObject_UNSAFE<T>(handleOrId);\n if (fluidObject.IFluidLoadable && fluidObject.handle) {\n directory.set(key, fluidObject.handle);\n }\n return fluidObject;\n } else {\n const handle = handleOrId?.IFluidHandle;\n return await (handle ? handle.get() : this.requestFluidObject_UNSAFE(key)) as T;\n }\n }\n\n /**\n * @deprecated\n * Gets the data store of a given id. Will follow the pattern of the container for waiting.\n * @param id - data store id\n */\n protected async requestFluidObject_UNSAFE<T extends IFluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends IFluidObject & FluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Called every time the data store is initialized, before initializingFirstTime or\n * initializingFromExisting is called.\n */\n protected async preInitialize(): Promise<void> { }\n\n /**\n * Called the first time the data store is initialized (new creations with a new\n * data store runtime)\n *\n * @param props - Optional props to be passed in on create\n */\n protected async initializingFirstTime(props?: S): Promise<void> { }\n\n /**\n * Called every time but the first time the data store is initialized (creations\n * with an existing data store runtime)\n */\n protected async initializingFromExisting(): Promise<void> { }\n\n /**\n * Called every time the data store is initialized after create or existing.\n */\n protected async hasInitialized(): Promise<void> { }\n\n /**\n * Called when the host container closes and disposes itself\n */\n public dispose(): void {\n super.dispose();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,OAAgB,cAClB,SAAQ,cAA2C;IAiDnD,YAAmB,KAA0B;QACzC,KAAK,EAAE,CAAC;QA/CJ,cAAS,GAAG,KAAK,CAAC;QAgDtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QAEjC,MAAM,CAAE,IAAI,CAAC,OAAe,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC7G,IAAI,CAAC,OAAe,CAAC,WAAW,GAAG,IAAI,CAAC;QAEzC,8GAA8G;QAC9G,4GAA4G;QAC5G,yBAAyB;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,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AAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAM,CAAC;SACnF;IACL,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,yBAAyB,CAAyB,EAAU;QACxE,OAAO,mBAAmB,CAAI,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACjF,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,UAAU,CAAuC,EAAU;QACvE,OAAO,mBAAmB,CAAI,IAAI,oBAAoB,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACzG,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAoB,CAAC;IAElD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAyC,IAAmB,CAAC;IAEnG;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAoB,CAAC;IAE7D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAoB,CAAC;IAEnD;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAED;;;;;;;;;;;GAWG;AACH,wDAAwD;AACxD,MAAM,OAAgB,oBACtB,SAAQ,cAAkE;CAEzE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IFluidObject,\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { AsyncFluidObjectProvider, FluidObjectKey } from \"@fluidframework/synthesize\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, DataObjectType, IDataObjectProps } from \"./types\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam I - The optional input types used to strongly type the data object\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n extends EventForwarder<DataObjectType<I, \"Events\">>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle, IFluidObject {\n private readonly innerHandle: IFluidHandle<this>;\n private _disposed = false;\n\n /**\n * This is your FluidDataStoreRuntime object\n */\n protected readonly runtime: IFluidDataStoreRuntime;\n\n /**\n * This context is used to talk up to the ContainerRuntime\n */\n protected readonly context: IFluidDataStoreContext;\n\n /**\n * Providers are IFluidObject keyed objects that provide back\n * a promise to the corresponding IFluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set IFluidObject interfaces in the generic O type for your data store\n */\n protected readonly providers:\n // eslint-disable-next-line @typescript-eslint/ban-types\n AsyncFluidObjectProvider<FluidObjectKey<DataObjectType<I, \"OptionalProviders\">>, FluidObjectKey<object>>;\n\n protected initProps?: DataObjectType<I, \"InitialState\">;\n\n protected initializeP: Promise<void> | undefined;\n\n public get disposed() { return this._disposed; }\n\n public get id() { return this.runtime.id; }\n public get IFluidRouter() { return this; }\n public get IFluidLoadable() { return this; }\n public get IFluidHandle() { return this.innerHandle; }\n\n /**\n * Handle to a data store\n */\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n\n public static async getDataObject(runtime: IFluidDataStoreRuntime) {\n const obj = (runtime as any)._dataObject as PureDataObject;\n assert(obj !== undefined, 0x0bc /* \"Runtime has no DataObject!\" */);\n await obj.finishInitialization(true);\n return obj;\n }\n\n public constructor(props: IDataObjectProps<I>) {\n super();\n this.runtime = props.runtime;\n this.context = props.context;\n this.providers = props.providers;\n this.initProps = props.initProps;\n\n assert((this.runtime as any)._dataObject === undefined, 0x0bd /* \"Object runtime already has DataObject!\" */);\n (this.runtime as any)._dataObject = this;\n\n // Create a FluidObjectHandle with empty string as `path`. This is because reaching this PureDataObject is the\n // same as reaching its routeContext (FluidDataStoreRuntime) so there is so the relative path to it from the\n // routeContext is empty.\n this.innerHandle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n\n // Container event handlers\n this.runtime.once(\"dispose\", () => {\n this._disposed = true;\n this.dispose();\n });\n }\n\n // #region IFluidRouter\n\n /**\n * Return this object if someone requests it directly\n * We will return this object in two scenarios:\n * 1. the request url is a \"/\"\n * 2. the request url is empty\n */\n public async request(req: IRequest): Promise<IResponse> {\n return defaultFluidObjectRequestHandler(this, req);\n }\n\n // #endregion IFluidRouter\n\n // #region IFluidLoadable\n\n // #endregion IFluidLoadable\n\n /**\n * Call this API to ensure PureDataObject is fully initialized\n * initialization happens on demand, only on as-needed bases.\n * In most cases you should allow factory/object to decide when to finish initialization.\n * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n * and need fully initialized object, then you can call this API to ensure object is fully initialized.\n */\n public async finishInitialization(existing: boolean): Promise<void> {\n if (this.initializeP !== undefined) {\n return this.initializeP;\n }\n this.initializeP = this.initializeInternal(existing);\n return this.initializeP;\n }\n\n /**\n * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n * generally not be done.\n *\n * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n * responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n await this.preInitialize();\n if (existing) {\n assert(this.initProps === undefined,\n 0x0be /* \"Trying to initialize from existing while initProps is set!\" */);\n await this.initializingFromExisting();\n } else {\n await this.initializingFirstTime(\n this.context.createProps as DataObjectType<I, \"InitialState\"> ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retreive Fluid object using the handle get or the older requestFluidObject_UNSAFE call to fetch by ID\n *\n * @param key - key that object (handle/id) is stored with in the directory\n * @param directory - directory containing the object\n * @param getObjectFromDirectory - optional callback for fetching object from the directory, allows users to\n * define custom types/getters for object retrieval\n */\n public async getFluidObjectFromDirectory<T extends IFluidObject & FluidObject & IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => string | IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleOrId = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n if (typeof handleOrId === \"string\") {\n // For backwards compatibility with older stored IDs\n // We update the storage with the handle so that this code path is less and less trafficked\n const fluidObject = await this.requestFluidObject_UNSAFE<T>(handleOrId);\n if (fluidObject.IFluidLoadable && fluidObject.handle) {\n directory.set(key, fluidObject.handle);\n }\n return fluidObject;\n } else {\n const handle = handleOrId?.IFluidHandle;\n return await (handle ? handle.get() : this.requestFluidObject_UNSAFE(key)) as T;\n }\n }\n\n /**\n * @deprecated\n * Gets the data store of a given id. Will follow the pattern of the container for waiting.\n * @param id - data store id\n */\n protected async requestFluidObject_UNSAFE<T extends IFluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends IFluidObject & FluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Called every time the data store is initialized, before initializingFirstTime or\n * initializingFromExisting is called.\n */\n protected async preInitialize(): Promise<void> { }\n\n /**\n * Called the first time the data store is initialized (new creations with a new\n * data store runtime)\n *\n * @param props - Optional props to be passed in on create\n */\n protected async initializingFirstTime(props?: DataObjectType<I, \"InitialState\">): Promise<void> { }\n\n /**\n * Called every time but the first time the data store is initialized (creations\n * with an existing data store runtime)\n */\n protected async initializingFromExisting(): Promise<void> { }\n\n /**\n * Called every time the data store is initialized after create or existing.\n */\n protected async hasInitialized(): Promise<void> { }\n\n /**\n * Called when the host container closes and disposes itself\n */\n public dispose(): void {\n super.dispose();\n }\n}\n\n/**\n * @deprecated - This type is meant to ease the transition from the old PureDataObject type to the new.\n * please migrate to PureDataObject.\n *\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport abstract class LegacyPureDataObject<O extends IFluidObject = object, S = undefined, E extends IEvent = IEvent>\nextends PureDataObject<{OptionalProviders: O, InitialState: S, Events: E}> {\n\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/data-objects/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { AsyncFluidObjectProvider, FluidObjectKey } from \"@fluidframework/synthesize\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\n\n/**\n * This type is used as the base generic input to DataObject and PureDataObject.\n */\nexport interface DataObjectTypes {\n /**\n * represents a type that will define optional providers that will be injected\n */\n OptionalProviders?: FluidObject;\n /**\n * the initial state type that the produced data object may take during creation\n */\n InitialState?: any;\n /**\n * represents events that will be available in the EventForwarder\n */\n Events?: IEvent;\n}\n\n/**\n * @internal This utility type pulls a specific key's type off the T and returns that,\n * or the default value if TKey is not specified by T\n */\nexport type DataObjectType<T extends DataObjectTypes, P extends keyof DataObjectTypes> =\n T[P] extends Required<DataObjectTypes>[P] ? T[P] : Required<DataObjectTypes>[P];\n\nexport interface IDataObjectProps<I extends DataObjectTypes = DataObjectTypes> {\n readonly runtime: IFluidDataStoreRuntime;\n readonly context: IFluidDataStoreContext;\n readonly providers:\n // eslint-disable-next-line @typescript-eslint/ban-types\n AsyncFluidObjectProvider<FluidObjectKey<DataObjectType<I, \"OptionalProviders\">>, FluidObjectKey<object>>;\n readonly initProps?: DataObjectType<I, \"InitialState\">;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/aqueduct",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0-46105",
|
|
4
4
|
"description": "A set of implementations for Fluid Framework interfaces.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -60,25 +60,25 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
62
62
|
"@fluidframework/common-utils": "^0.32.1",
|
|
63
|
-
"@fluidframework/container-definitions": "^0.
|
|
64
|
-
"@fluidframework/container-loader": "
|
|
65
|
-
"@fluidframework/container-runtime": "
|
|
66
|
-
"@fluidframework/container-runtime-definitions": "
|
|
63
|
+
"@fluidframework/container-definitions": "^0.43.0-0",
|
|
64
|
+
"@fluidframework/container-loader": "0.53.0-46105",
|
|
65
|
+
"@fluidframework/container-runtime": "0.53.0-46105",
|
|
66
|
+
"@fluidframework/container-runtime-definitions": "0.53.0-46105",
|
|
67
67
|
"@fluidframework/core-interfaces": "^0.41.0",
|
|
68
|
-
"@fluidframework/datastore": "
|
|
69
|
-
"@fluidframework/datastore-definitions": "
|
|
70
|
-
"@fluidframework/map": "
|
|
71
|
-
"@fluidframework/request-handler": "
|
|
72
|
-
"@fluidframework/runtime-definitions": "
|
|
73
|
-
"@fluidframework/runtime-utils": "
|
|
74
|
-
"@fluidframework/synthesize": "
|
|
75
|
-
"@fluidframework/view-interfaces": "
|
|
68
|
+
"@fluidframework/datastore": "0.53.0-46105",
|
|
69
|
+
"@fluidframework/datastore-definitions": "0.53.0-46105",
|
|
70
|
+
"@fluidframework/map": "0.53.0-46105",
|
|
71
|
+
"@fluidframework/request-handler": "0.53.0-46105",
|
|
72
|
+
"@fluidframework/runtime-definitions": "0.53.0-46105",
|
|
73
|
+
"@fluidframework/runtime-utils": "0.53.0-46105",
|
|
74
|
+
"@fluidframework/synthesize": "0.53.0-46105",
|
|
75
|
+
"@fluidframework/view-interfaces": "0.53.0-46105",
|
|
76
76
|
"uuid": "^8.3.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@fluidframework/build-common": "^0.23.0",
|
|
80
80
|
"@fluidframework/eslint-config-fluid": "^0.24.0",
|
|
81
|
-
"@fluidframework/mocha-test-setup": "
|
|
81
|
+
"@fluidframework/mocha-test-setup": "0.53.0-46105",
|
|
82
82
|
"@microsoft/api-extractor": "^7.16.1",
|
|
83
83
|
"@types/mocha": "^8.2.2",
|
|
84
84
|
"@types/node": "^12.19.0",
|