@fluidframework/aqueduct 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229

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.
Files changed (83) hide show
  1. package/README.md +29 -29
  2. package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts +9 -5
  3. package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
  4. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js +20 -7
  5. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
  6. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts +2 -1
  7. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  8. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js +2 -5
  9. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  10. package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
  11. package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
  12. package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
  13. package/dist/data-object-factories/pureDataObjectFactory.js +4 -2
  14. package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
  15. package/dist/data-objects/dataObject.d.ts.map +1 -1
  16. package/dist/data-objects/dataObject.js +1 -1
  17. package/dist/data-objects/dataObject.js.map +1 -1
  18. package/dist/data-objects/pureDataObject.d.ts +1 -6
  19. package/dist/data-objects/pureDataObject.d.ts.map +1 -1
  20. package/dist/data-objects/pureDataObject.js +15 -14
  21. package/dist/data-objects/pureDataObject.js.map +1 -1
  22. package/dist/data-objects/types.d.ts.map +1 -1
  23. package/dist/data-objects/types.js.map +1 -1
  24. package/dist/index.d.ts +2 -3
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -6
  27. package/dist/index.js.map +1 -1
  28. package/dist/request-handlers/requestHandlers.d.ts +1 -1
  29. package/dist/request-handlers/requestHandlers.d.ts.map +1 -1
  30. package/dist/request-handlers/requestHandlers.js +4 -2
  31. package/dist/request-handlers/requestHandlers.js.map +1 -1
  32. package/dist/test/defaultRoute.spec.js +3 -1
  33. package/dist/test/defaultRoute.spec.js.map +1 -1
  34. package/dist/test/tsconfig.tsbuildinfo +1 -1
  35. package/dist/test/types/validateAqueductPrevious.generated.js +8 -18
  36. package/dist/test/types/validateAqueductPrevious.generated.js.map +1 -1
  37. package/dist/utils/containerInteractions.d.ts.map +1 -1
  38. package/dist/utils/containerInteractions.js.map +1 -1
  39. package/dist/utils/index.d.ts +0 -1
  40. package/dist/utils/index.d.ts.map +1 -1
  41. package/dist/utils/index.js +1 -3
  42. package/dist/utils/index.js.map +1 -1
  43. package/lib/container-runtime-factories/baseContainerRuntimeFactory.js +22 -9
  44. package/lib/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
  45. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js +2 -5
  46. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  47. package/lib/data-object-factories/dataObjectFactory.js +1 -1
  48. package/lib/data-object-factories/dataObjectFactory.js.map +1 -1
  49. package/lib/data-object-factories/pureDataObjectFactory.js +4 -2
  50. package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -1
  51. package/lib/data-objects/dataObject.js +1 -1
  52. package/lib/data-objects/dataObject.js.map +1 -1
  53. package/lib/data-objects/pureDataObject.js +15 -14
  54. package/lib/data-objects/pureDataObject.js.map +1 -1
  55. package/lib/data-objects/types.js.map +1 -1
  56. package/lib/index.js +2 -3
  57. package/lib/index.js.map +1 -1
  58. package/lib/request-handlers/requestHandlers.js +4 -2
  59. package/lib/request-handlers/requestHandlers.js.map +1 -1
  60. package/lib/utils/containerInteractions.js.map +1 -1
  61. package/lib/utils/index.js +0 -1
  62. package/lib/utils/index.js.map +1 -1
  63. package/package.json +58 -58
  64. package/dist/container-services/containerServices.d.ts +0 -27
  65. package/dist/container-services/containerServices.d.ts.map +0 -1
  66. package/dist/container-services/containerServices.js +0 -84
  67. package/dist/container-services/containerServices.js.map +0 -1
  68. package/dist/container-services/index.d.ts +0 -6
  69. package/dist/container-services/index.d.ts.map +0 -1
  70. package/dist/container-services/index.js +0 -12
  71. package/dist/container-services/index.js.map +0 -1
  72. package/dist/test/containerServices.spec.js +0 -121
  73. package/dist/test/containerServices.spec.js.map +0 -1
  74. package/dist/utils/attachUtils.d.ts +0 -7
  75. package/dist/utils/attachUtils.d.ts.map +0 -1
  76. package/dist/utils/attachUtils.js +0 -20
  77. package/dist/utils/attachUtils.js.map +0 -1
  78. package/lib/container-services/containerServices.js +0 -79
  79. package/lib/container-services/containerServices.js.map +0 -1
  80. package/lib/container-services/index.js +0 -6
  81. package/lib/container-services/index.js.map +0 -1
  82. package/lib/utils/attachUtils.js +0 -16
  83. package/lib/utils/attachUtils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAYtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,OAAgB,cAClB,SAAQ,cAAoC;IAsD5C,YAAmB,KAA0B;QACzC,KAAK,EAAE,CAAC;QApDJ,cAAS,GAAG,KAAK,CAAC;QAqDtB,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;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,EAAE,CAAC;SACvB;IACL,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,UAAU,CAAwB,EAAU;QACxD,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,KAAyB,IAAmB,CAAC;IAEnF;;;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 { IEvent } from \"@fluidframework/common-definitions\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport {\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { AsyncFluidObjectProvider } from \"@fluidframework/synthesize\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, 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<I[\"Events\"] & IEvent>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle {\n\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 FluidObject keyed objects that provide back\n * a promise to the corresponding FluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n */\n protected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n protected initProps?: 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() {\n return this.handle;\n }\n\n /**\n * Handle to a data store\n */\n public get handle(): IFluidHandle<this> {\n // PureDataObjectFactory already provides an entryPoint initialization function to the data store runtime,\n // so this object should always have access to a non-null entryPoint. Need to cast because PureDataObject\n // tried to be too smart with its typing for handles :).\n assert(this.runtime.entryPoint !== undefined, 0x46b /* EntryPoint was undefined */);\n return this.runtime.entryPoint as IFluidHandle<this>;\n }\n\n public static async getDataObject(runtime: IFluidDataStoreRuntime) {\n const obj = await runtime.entryPoint?.get();\n assert(obj !== undefined, 0x0bc /* \"The runtime's handle is not initialized yet!\" */);\n return obj as PureDataObject;\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 // 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 *\n * 1. the request url is a \"/\"\n *\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 /**\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 a 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 I[\"InitialState\"] ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retrieve Fluid object using the handle get\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 IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleMaybe = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n const handle = handleMaybe?.IFluidHandle;\n if (handle) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return handle.get();\n }\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends 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?: 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"]}
1
+ {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAatE,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,OAAgB,cACrB,SAAQ,cAAoC;IA8D5C,YAAmB,KAA0B;QAC5C,KAAK,EAAE,CAAC;QA5DD,cAAS,GAAG,KAAK,CAAC;QA6DzB,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,CACJ,IAAI,CAAC,OAAe,CAAC,WAAW,KAAK,SAAS,EAC/C,KAAK,CAAC,8CAA8C,CACpD,CAAC;QACD,IAAI,CAAC,OAAe,CAAC,WAAW,GAAG,IAAI,CAAC;QAEzC,2BAA2B;QAC3B,IAAI,CAA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G;IACI,OAAO;QACb,KAAK,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport {\n\tIFluidHandle,\n\tIFluidLoadable,\n\tIFluidRouter,\n\tIProvideFluidHandle,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { AsyncFluidObjectProvider } from \"@fluidframework/synthesize\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, 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\textends EventForwarder<I[\"Events\"] & IEvent>\n\timplements IFluidLoadable, IFluidRouter, IProvideFluidHandle\n{\n\tprivate _disposed = false;\n\n\t/**\n\t * This is your FluidDataStoreRuntime object\n\t */\n\tprotected readonly runtime: IFluidDataStoreRuntime;\n\n\t/**\n\t * This context is used to talk up to the ContainerRuntime\n\t */\n\tprotected readonly context: IFluidDataStoreContext;\n\n\t/**\n\t * Providers are FluidObject keyed objects that provide back\n\t * a promise to the corresponding FluidObject or undefined.\n\t * Providers injected/provided by the Container and/or HostingApplication\n\t *\n\t * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n\t */\n\tprotected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n\tprotected initProps?: I[\"InitialState\"];\n\n\tprotected initializeP: Promise<void> | undefined;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get id() {\n\t\treturn this.runtime.id;\n\t}\n\tpublic get IFluidRouter() {\n\t\treturn this;\n\t}\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\tpublic get IFluidHandle() {\n\t\treturn this.handle;\n\t}\n\n\t/**\n\t * Handle to a data store\n\t */\n\tpublic get handle(): IFluidHandle<this> {\n\t\t// PureDataObjectFactory already provides an entryPoint initialization function to the data store runtime,\n\t\t// so this object should always have access to a non-null entryPoint. Need to cast because PureDataObject\n\t\t// tried to be too smart with its typing for handles :).\n\t\tassert(this.runtime.entryPoint !== undefined, 0x46b /* EntryPoint was undefined */);\n\t\treturn this.runtime.entryPoint as IFluidHandle<this>;\n\t}\n\n\tpublic static async getDataObject(runtime: IFluidDataStoreRuntime) {\n\t\tconst obj = await runtime.entryPoint?.get();\n\t\tassert(obj !== undefined, 0x0bc /* \"The runtime's handle is not initialized yet!\" */);\n\t\treturn obj as PureDataObject;\n\t}\n\n\tpublic constructor(props: IDataObjectProps<I>) {\n\t\tsuper();\n\t\tthis.runtime = props.runtime;\n\t\tthis.context = props.context;\n\t\tthis.providers = props.providers;\n\t\tthis.initProps = props.initProps;\n\n\t\tassert(\n\t\t\t(this.runtime as any)._dataObject === undefined,\n\t\t\t0x0bd /* \"Object runtime already has DataObject!\" */,\n\t\t);\n\t\t(this.runtime as any)._dataObject = this;\n\n\t\t// Container event handlers\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis._disposed = true;\n\t\t\tthis.dispose();\n\t\t});\n\t}\n\n\t// #region IFluidRouter\n\n\t/**\n\t * Return this object if someone requests it directly\n\t * We will return this object in two scenarios:\n\t *\n\t * 1. the request url is a \"/\"\n\t *\n\t * 2. the request url is empty\n\t */\n\tpublic async request(req: IRequest): Promise<IResponse> {\n\t\treturn defaultFluidObjectRequestHandler(this, req);\n\t}\n\n\t// #endregion IFluidRouter\n\n\t/**\n\t * Call this API to ensure PureDataObject is fully initialized.\n\t * Initialization happens on demand, only on as-needed bases.\n\t * In most cases you should allow factory/object to decide when to finish initialization.\n\t * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n\t * and need a fully initialized object, then you can call this API to ensure object is fully initialized.\n\t */\n\tpublic async finishInitialization(existing: boolean): Promise<void> {\n\t\tif (this.initializeP !== undefined) {\n\t\t\treturn this.initializeP;\n\t\t}\n\t\tthis.initializeP = this.initializeInternal(existing);\n\t\treturn this.initializeP;\n\t}\n\n\t/**\n\t * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n\t * generally not be done.\n\t *\n\t * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n\t * responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tawait this.preInitialize();\n\t\tif (existing) {\n\t\t\tassert(\n\t\t\t\tthis.initProps === undefined,\n\t\t\t\t0x0be /* \"Trying to initialize from existing while initProps is set!\" */,\n\t\t\t);\n\t\t\tawait this.initializingFromExisting();\n\t\t} else {\n\t\t\tawait this.initializingFirstTime(\n\t\t\t\t(this.context.createProps as I[\"InitialState\"]) ?? this.initProps,\n\t\t\t);\n\t\t}\n\t\tawait this.hasInitialized();\n\t}\n\n\t/**\n\t * Retrieve Fluid object using the handle get\n\t *\n\t * @param key - key that object (handle/id) is stored with in the directory\n\t * @param directory - directory containing the object\n\t * @param getObjectFromDirectory - optional callback for fetching object from the directory, allows users to\n\t * define custom types/getters for object retrieval\n\t */\n\tpublic async getFluidObjectFromDirectory<T extends IFluidLoadable>(\n\t\tkey: string,\n\t\tdirectory: IDirectory,\n\t\tgetObjectFromDirectory?: (id: string, directory: IDirectory) => IFluidHandle | undefined,\n\t): Promise<T | undefined> {\n\t\tconst handleMaybe = getObjectFromDirectory\n\t\t\t? getObjectFromDirectory(key, directory)\n\t\t\t: directory.get(key);\n\t\tconst handle = handleMaybe?.IFluidHandle;\n\t\tif (handle) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn handle.get();\n\t\t}\n\t}\n\n\t/**\n\t * Called every time the data store is initialized, before initializingFirstTime or\n\t * initializingFromExisting is called.\n\t */\n\tprotected async preInitialize(): Promise<void> {}\n\n\t/**\n\t * Called the first time the data store is initialized (new creations with a new\n\t * data store runtime)\n\t *\n\t * @param props - Optional props to be passed in on create\n\t */\n\tprotected async initializingFirstTime(props?: I[\"InitialState\"]): Promise<void> {}\n\n\t/**\n\t * Called every time but the first time the data store is initialized (creations\n\t * with an existing data store runtime)\n\t */\n\tprotected async initializingFromExisting(): Promise<void> {}\n\n\t/**\n\t * Called every time the data store is initialized after create or existing.\n\t */\n\tprotected async hasInitialized(): Promise<void> {}\n\n\t/**\n\t * Called when the host container closes and disposes itself\n\t */\n\tpublic dispose(): void {\n\t\tsuper.dispose();\n\t}\n}\n"]}
@@ -1 +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 } 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\nexport interface IDataObjectProps<I extends DataObjectTypes = DataObjectTypes> {\n readonly runtime: IFluidDataStoreRuntime;\n readonly context: IFluidDataStoreContext;\n readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n readonly initProps?: I[\"InitialState\"];\n}\n"]}
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 { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { AsyncFluidObjectProvider } 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\t/**\n\t * represents a type that will define optional providers that will be injected\n\t */\n\tOptionalProviders?: FluidObject;\n\t/**\n\t * the initial state type that the produced data object may take during creation\n\t */\n\tInitialState?: any;\n\t/**\n\t * represents events that will be available in the EventForwarder\n\t */\n\tEvents?: IEvent;\n}\n\nexport interface IDataObjectProps<I extends DataObjectTypes = DataObjectTypes> {\n\treadonly runtime: IFluidDataStoreRuntime;\n\treadonly context: IFluidDataStoreContext;\n\treadonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\treadonly initProps?: I[\"InitialState\"];\n}\n"]}
package/lib/index.js CHANGED
@@ -16,10 +16,9 @@
16
16
  *
17
17
  * @packageDocumentation
18
18
  */
19
- export { DataObjectFactory, PureDataObjectFactory } from "./data-object-factories";
19
+ export { DataObjectFactory, PureDataObjectFactory, } from "./data-object-factories";
20
20
  export { DataObject, PureDataObject } from "./data-objects";
21
21
  export { BaseContainerRuntimeFactory, ContainerRuntimeFactoryWithDefaultDataStore, } from "./container-runtime-factories";
22
- export { BaseContainerService, generateContainerServicesRequestHandler, serviceRoutePathRoot, } from "./container-services";
23
22
  export { defaultFluidObjectRequestHandler, defaultRouteRequestHandler, mountableViewRequestHandler, } from "./request-handlers";
24
- export { getDefaultObjectFromContainer, getObjectFromContainer, getObjectWithIdFromContainer, waitForAttach, } from "./utils";
23
+ export { getDefaultObjectFromContainer, getObjectFromContainer, getObjectWithIdFromContainer, } from "./utils";
25
24
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,iBAAiB,EAA0B,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,UAAU,EAAqC,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EACN,2BAA2B,EAC3B,2CAA2C,GAC3C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,oBAAoB,EAEpB,uCAAuC,EACvC,oBAAoB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,gCAAgC,EAChC,0BAA0B,EAC1B,2BAA2B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,aAAa,GACb,MAAM,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `aqueduct` package is a library for building Fluid objects and Fluid\n * containers within the Fluid Framework. Its goal is to provide a thin base\n * layer over the existing Fluid Framework interfaces that allows developers to\n * get started quickly.\n *\n * @remarks\n * About the library name: An \"aqueduct\" is a way to transport water from a source\n * to another location. The library name was chosen because its purpose is to\n * facilitate using lower level constructs and therefore handle 'fluid' items\n * same as an aqueduct.\n *\n * @packageDocumentation\n */\n\nexport { DataObjectFactory, IRootDataObjectFactory, PureDataObjectFactory } from \"./data-object-factories\";\nexport { DataObject, DataObjectTypes, IDataObjectProps, PureDataObject } from \"./data-objects\";\nexport {\n\tBaseContainerRuntimeFactory,\n\tContainerRuntimeFactoryWithDefaultDataStore,\n} from \"./container-runtime-factories\";\nexport {\n\tBaseContainerService,\n\tContainerServiceRegistryEntries,\n\tgenerateContainerServicesRequestHandler,\n\tserviceRoutePathRoot,\n} from \"./container-services\";\nexport {\n\tdefaultFluidObjectRequestHandler,\n\tdefaultRouteRequestHandler,\n\tmountableViewRequestHandler,\n} from \"./request-handlers\";\nexport {\n\tgetDefaultObjectFromContainer,\n\tgetObjectFromContainer,\n\tgetObjectWithIdFromContainer,\n\twaitForAttach,\n} from \"./utils\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EAEjB,qBAAqB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAqC,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EACN,2BAA2B,EAC3B,2CAA2C,GAC3C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,gCAAgC,EAChC,0BAA0B,EAC1B,2BAA2B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,GAC5B,MAAM,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `aqueduct` package is a library for building Fluid objects and Fluid\n * containers within the Fluid Framework. Its goal is to provide a thin base\n * layer over the existing Fluid Framework interfaces that allows developers to\n * get started quickly.\n *\n * @remarks\n * About the library name: An \"aqueduct\" is a way to transport water from a source\n * to another location. The library name was chosen because its purpose is to\n * facilitate using lower level constructs and therefore handle 'fluid' items\n * same as an aqueduct.\n *\n * @packageDocumentation\n */\n\nexport {\n\tDataObjectFactory,\n\tIRootDataObjectFactory,\n\tPureDataObjectFactory,\n} from \"./data-object-factories\";\nexport { DataObject, DataObjectTypes, IDataObjectProps, PureDataObject } from \"./data-objects\";\nexport {\n\tBaseContainerRuntimeFactory,\n\tContainerRuntimeFactoryWithDefaultDataStore,\n} from \"./container-runtime-factories\";\nexport {\n\tdefaultFluidObjectRequestHandler,\n\tdefaultRouteRequestHandler,\n\tmountableViewRequestHandler,\n} from \"./request-handlers\";\nexport {\n\tgetDefaultObjectFromContainer,\n\tgetObjectFromContainer,\n\tgetObjectWithIdFromContainer,\n} from \"./utils\";\n"]}
@@ -32,7 +32,9 @@ export const mountableViewRequestHandler = (MountableViewClass, handlers) => {
32
32
  };
33
33
  }
34
34
  const response = await nestedHandler(newRequest, runtime);
35
- if (mountableView && response.status === 200 && MountableViewClass.canMount(response.value)) {
35
+ if (mountableView &&
36
+ response.status === 200 &&
37
+ MountableViewClass.canMount(response.value)) {
36
38
  return {
37
39
  status: 200,
38
40
  mimeType: "fluid/object",
@@ -53,7 +55,7 @@ export const defaultRouteRequestHandler = (defaultRootId) => {
53
55
  if (parser.pathParts.length === 0) {
54
56
  return runtime.IFluidHandleContext.resolveHandle({
55
57
  url: `/${defaultRootId}${parser.query}`,
56
- headers: request.headers
58
+ headers: request.headers,
57
59
  });
58
60
  }
59
61
  return undefined; // continue search
@@ -1 +1 @@
1
- {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../src/request-handlers/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAyB,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACpC,CAAC,kBAA4C,EAAE,QAAiC,EAAE,EAAE;IAChF,MAAM,aAAa,GAAG,0BAA0B,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9D,OAAO,KAAK,EAAE,OAAsB,EAAE,OAA0B,EAAE,EAAE;;QAChE,MAAM,aAAa,GAAG,C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;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB,EAAE,OAAiB;IACxF,OAAO,OAAO,CAAC,GAAG,KAAK,EAAE,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;QAC5E,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;QAC/D,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FluidObject, IRequest, IRequestHeader, IResponse } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidMountableViewClass } from \"@fluidframework/view-interfaces\";\nimport { RuntimeRequestHandler, buildRuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\n\n/**\n * A mountable view is only required if the view needs to be mounted across a bundle boundary. Mounting across\n * bundle boundaries breaks some frameworks, so the mountable view is used to ensure the mounting is done within\n * the same bundle as the view. For example, React hooks don't work if mounted across bundles since there will\n * be two React instances, breaking the Rules of Hooks. When cross-bundle mounting isn't required, the mountable\n * view isn't necessary.\n *\n * When a request is received with a mountableView: true header, this request handler will reissue the request\n * without the header, and respond with a mountable view of the given class using the response.\n * @param MountableViewClass - The type of mountable view to use when responding\n */\nexport const mountableViewRequestHandler =\n (MountableViewClass: IFluidMountableViewClass, handlers: RuntimeRequestHandler[]) => {\n const nestedHandler = buildRuntimeRequestHandler(...handlers);\n return async (request: RequestParser, runtime: IContainerRuntime) => {\n const mountableView = request.headers?.mountableView === true;\n let newRequest: IRequest = request;\n if (mountableView) {\n // Reissue the request without the mountableView header.\n // We'll repack whatever the response is if we can.\n const headers: IRequestHeader = { ...request.headers };\n delete (headers as any).mountableView;\n newRequest = {\n url: request.url,\n headers,\n };\n }\n const response = await nestedHandler(newRequest, runtime);\n\n if (mountableView && response.status === 200 && MountableViewClass.canMount(response.value)) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: new MountableViewClass(response.value),\n };\n }\n return response;\n };\n };\n\n/**\n * Pipe through container request into internal request.\n * If request is empty and default url is provided, redirect request to such default url.\n * @param defaultRootId - optional default root data store ID to pass request in case request is empty.\n */\nexport const defaultRouteRequestHandler = (defaultRootId: string) => {\n return async (request: IRequest, runtime: IContainerRuntime) => {\n const parser = RequestParser.create(request);\n if (parser.pathParts.length === 0) {\n return runtime.IFluidHandleContext.resolveHandle({\n url: `/${defaultRootId}${parser.query}`,\n headers: request.headers });\n }\n return undefined; // continue search\n };\n};\n\n/**\n * Default request handler for a Fluid object that returns the object itself if:\n *\n * 1. the request url is empty\n *\n * 2. the request url is \"/\"\n *\n * 3. the request url starts with \"/\" and is followed by a query param, such as /?key=value\n *\n * Returns a 404 error for any other url.\n */\nexport function defaultFluidObjectRequestHandler(fluidObject: FluidObject, request: IRequest): IResponse {\n return request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")\n ? { mimeType: \"fluid/object\", status: 200, value: fluidObject }\n : create404Response(request);\n}\n"]}
1
+ {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../src/request-handlers/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAyB,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAC1C,kBAA4C,EAC5C,QAAiC,EAChC,EAAE;IACH,MAAM,aAAa,GAAG,0BAA0B,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9D,OAAO,KAAK,EAAE,OAAsB,EAAE,OAA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AAkB;IACrC,CAAC,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gCAAgC,CAC/C,WAAwB,EACxB,OAAiB;IAEjB,OAAO,OAAO,CAAC,GAAG,KAAK,EAAE,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;QAC/E,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;QAC/D,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FluidObject, IRequest, IRequestHeader, IResponse } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport type { IFluidMountableViewClass } from \"@fluidframework/view-interfaces\";\nimport { RuntimeRequestHandler, buildRuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\n\n/**\n * A mountable view is only required if the view needs to be mounted across a bundle boundary. Mounting across\n * bundle boundaries breaks some frameworks, so the mountable view is used to ensure the mounting is done within\n * the same bundle as the view. For example, React hooks don't work if mounted across bundles since there will\n * be two React instances, breaking the Rules of Hooks. When cross-bundle mounting isn't required, the mountable\n * view isn't necessary.\n *\n * When a request is received with a mountableView: true header, this request handler will reissue the request\n * without the header, and respond with a mountable view of the given class using the response.\n * @param MountableViewClass - The type of mountable view to use when responding\n */\nexport const mountableViewRequestHandler = (\n\tMountableViewClass: IFluidMountableViewClass,\n\thandlers: RuntimeRequestHandler[],\n) => {\n\tconst nestedHandler = buildRuntimeRequestHandler(...handlers);\n\treturn async (request: RequestParser, runtime: IContainerRuntime) => {\n\t\tconst mountableView = request.headers?.mountableView === true;\n\t\tlet newRequest: IRequest = request;\n\t\tif (mountableView) {\n\t\t\t// Reissue the request without the mountableView header.\n\t\t\t// We'll repack whatever the response is if we can.\n\t\t\tconst headers: IRequestHeader = { ...request.headers };\n\t\t\tdelete (headers as any).mountableView;\n\t\t\tnewRequest = {\n\t\t\t\turl: request.url,\n\t\t\t\theaders,\n\t\t\t};\n\t\t}\n\t\tconst response = await nestedHandler(newRequest, runtime);\n\n\t\tif (\n\t\t\tmountableView &&\n\t\t\tresponse.status === 200 &&\n\t\t\tMountableViewClass.canMount(response.value)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tstatus: 200,\n\t\t\t\tmimeType: \"fluid/object\",\n\t\t\t\tvalue: new MountableViewClass(response.value),\n\t\t\t};\n\t\t}\n\t\treturn response;\n\t};\n};\n\n/**\n * Pipe through container request into internal request.\n * If request is empty and default url is provided, redirect request to such default url.\n * @param defaultRootId - optional default root data store ID to pass request in case request is empty.\n */\nexport const defaultRouteRequestHandler = (defaultRootId: string) => {\n\treturn async (request: IRequest, runtime: IContainerRuntime) => {\n\t\tconst parser = RequestParser.create(request);\n\t\tif (parser.pathParts.length === 0) {\n\t\t\treturn runtime.IFluidHandleContext.resolveHandle({\n\t\t\t\turl: `/${defaultRootId}${parser.query}`,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\t\t}\n\t\treturn undefined; // continue search\n\t};\n};\n\n/**\n * Default request handler for a Fluid object that returns the object itself if:\n *\n * 1. the request url is empty\n *\n * 2. the request url is \"/\"\n *\n * 3. the request url starts with \"/\" and is followed by a query param, such as /?key=value\n *\n * Returns a 404 error for any other url.\n */\nexport function defaultFluidObjectRequestHandler(\n\tfluidObject: FluidObject,\n\trequest: IRequest,\n): IResponse {\n\treturn request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")\n\t\t? { mimeType: \"fluid/object\", status: 200, value: fluidObject }\n\t\t: create404Response(request);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"containerInteractions.js","sourceRoot":"","sources":["../../src/utils/container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,IAAY,EAAE,SAAqB;IACnC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAExD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,mDAAmD,IAAI,GAAG,CAAC,CAAC;KAC/E;SAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,GAAG,CAAC,CAAC;KAC7D;IAED,+DAA+D;IAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { IContainer } from \"@fluidframework/container-definitions\";\n\n/**\n * Helper function for getting the default Fluid Object from a Container. This function only works for\n * Containers that support \"/\" request.\n *\n * @typeParam T - Defines the type you expect to be returned.\n *\n * @param container - Container you're attempting to get the object from\n */\nexport async function getDefaultObjectFromContainer<T = FluidObject>(container: IContainer): Promise<T> {\n const url = \"/\";\n const response = await container.request({ url });\n\n // Verify the response\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object at URL: \"${url}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response from URL: \"${url}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n\n/**\n * Helper function for getting as Fluid Object from a Container given a Unique Id. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * @typeParam T - Defines the type you expect to be returned.\n *\n * @param id - Unique id of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectWithIdFromContainer<T = FluidObject>(\n id: string, container: IContainer): Promise<T> {\n const url = `/${id}`;\n const response = await container.request({ url });\n\n // Verify the response\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object with ID: \"${id}\" from URL: \"${url}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response for ID: \"${id}\" from URL: \"${url}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n\n/**\n * Helper function for getting a Fluid Object from a Container given a path/url. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * @typeParam T - Defines the type you expect to be returned.\n *\n * @param path - Unique path/url of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectFromContainer<T = FluidObject>(\n path: string, container: IContainer): Promise<T> {\n const response = await container.request({ url: path });\n\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object with from URL: \"${path}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response for from URL: \"${path}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n"]}
1
+ {"version":3,"file":"containerInteractions.js","sourceRoot":"","sources":["../../src/utils/containerInteractions.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,SAAqB;IAErB,MAAM,GAAG,GAAG,GAAG,CAAC;IAChB,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAElD,sBAAsB;IACtB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;QACpE,MAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,GAAG,CAAC,CAAC;KACpE;SAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,GAAG,CAAC,CAAC;KACrD;IAED,+DAA+D;IAC/D,OAAO,Q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idObject } from \"@fluidframework/core-interfaces\";\nimport { IContainer } from \"@fluidframework/container-definitions\";\n\n/**\n * Helper function for getting the default Fluid Object from a Container. This function only works for\n * Containers that support \"/\" request.\n *\n * @typeParam T - Defines the type you expect to be returned.\n *\n * @param container - Container you're attempting to get the object from\n */\nexport async function getDefaultObjectFromContainer<T = FluidObject>(\n\tcontainer: IContainer,\n): Promise<T> {\n\tconst url = \"/\";\n\tconst response = await container.request({ url });\n\n\t// Verify the response\n\tif (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n\t\tthrow new Error(`Unable to retrieve Fluid object at URL: \"${url}\"`);\n\t} else if (response.value === undefined) {\n\t\tthrow new Error(`Empty response from URL: \"${url}\"`);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn response.value;\n}\n\n/**\n * Helper function for getting as Fluid Object from a Container given a Unique Id. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * @typeParam T - Defines the type you expect to be returned.\n *\n * @param id - Unique id of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectWithIdFromContainer<T = FluidObject>(\n\tid: string,\n\tcontainer: IContainer,\n): Promise<T> {\n\tconst url = `/${id}`;\n\tconst response = await container.request({ url });\n\n\t// Verify the response\n\tif (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n\t\tthrow new Error(`Unable to retrieve Fluid object with ID: \"${id}\" from URL: \"${url}\"`);\n\t} else if (response.value === undefined) {\n\t\tthrow new Error(`Empty response for ID: \"${id}\" from URL: \"${url}\"`);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn response.value;\n}\n\n/**\n * Helper function for getting a Fluid Object from a Container given a path/url. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * @typeParam T - Defines the type you expect to be returned.\n *\n * @param path - Unique path/url of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectFromContainer<T = FluidObject>(\n\tpath: string,\n\tcontainer: IContainer,\n): Promise<T> {\n\tconst response = await container.request({ url: path });\n\n\tif (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n\t\tthrow new Error(`Unable to retrieve Fluid object with from URL: \"${path}\"`);\n\t} else if (response.value === undefined) {\n\t\tthrow new Error(`Empty response for from URL: \"${path}\"`);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn response.value;\n}\n"]}
@@ -2,6 +2,5 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { waitForAttach } from "./attachUtils";
6
5
  export { getDefaultObjectFromContainer, getObjectFromContainer, getObjectWithIdFromContainer, } from "./containerInteractions";
7
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { waitForAttach } from \"./attachUtils\";\nexport {\n\tgetDefaultObjectFromContainer,\n\tgetObjectFromContainer,\n\tgetObjectWithIdFromContainer,\n} from \"./containerInteractions\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tgetDefaultObjectFromContainer,\n\tgetObjectFromContainer,\n\tgetObjectWithIdFromContainer,\n} from \"./containerInteractions\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/aqueduct",
3
- "version": "2.0.0-dev.2.3.0.115467",
3
+ "version": "2.0.0-dev.4.1.0.148229",
4
4
  "description": "A set of implementations for Fluid Framework interfaces.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -18,32 +18,6 @@
18
18
  "dist/**/*",
19
19
  "lib/**/*"
20
20
  ],
21
- "scripts": {
22
- "build": "concurrently npm:build:compile npm:lint && npm run build:docs",
23
- "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
24
- "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
25
- "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
26
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
27
- "build:full": "npm run build",
28
- "build:full:compile": "npm run build:compile",
29
- "build:test": "tsc --project ./src/test/tsconfig.json",
30
- "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
31
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
32
- "eslint": "eslint --format stylish src",
33
- "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
34
- "format": "npm run prettier:fix",
35
- "lint": "npm run eslint",
36
- "lint:fix": "npm run eslint:fix",
37
- "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
38
- "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
39
- "test": "npm run test:mocha",
40
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
41
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
42
- "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
43
- "tsc": "tsc",
44
- "typetests:gen": "flub generate typetests --generate --dir .",
45
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
46
- },
47
21
  "nyc": {
48
22
  "all": true,
49
23
  "cache-dir": "nyc/.cache",
@@ -66,48 +40,74 @@
66
40
  },
67
41
  "dependencies": {
68
42
  "@fluidframework/common-definitions": "^0.20.1",
69
- "@fluidframework/common-utils": "^1.0.0",
70
- "@fluidframework/container-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
71
- "@fluidframework/container-loader": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
72
- "@fluidframework/container-runtime": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
73
- "@fluidframework/container-runtime-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
74
- "@fluidframework/core-interfaces": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
75
- "@fluidframework/datastore": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
76
- "@fluidframework/datastore-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
77
- "@fluidframework/map": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
78
- "@fluidframework/request-handler": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
79
- "@fluidframework/runtime-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
80
- "@fluidframework/runtime-utils": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
81
- "@fluidframework/synthesize": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
82
- "@fluidframework/view-interfaces": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
43
+ "@fluidframework/common-utils": "^1.1.1",
44
+ "@fluidframework/container-definitions": "2.0.0-dev.4.1.0.148229",
45
+ "@fluidframework/container-loader": "2.0.0-dev.4.1.0.148229",
46
+ "@fluidframework/container-runtime": "2.0.0-dev.4.1.0.148229",
47
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev.4.1.0.148229",
48
+ "@fluidframework/core-interfaces": "2.0.0-dev.4.1.0.148229",
49
+ "@fluidframework/datastore": "2.0.0-dev.4.1.0.148229",
50
+ "@fluidframework/datastore-definitions": "2.0.0-dev.4.1.0.148229",
51
+ "@fluidframework/map": "2.0.0-dev.4.1.0.148229",
52
+ "@fluidframework/request-handler": "2.0.0-dev.4.1.0.148229",
53
+ "@fluidframework/runtime-definitions": "2.0.0-dev.4.1.0.148229",
54
+ "@fluidframework/runtime-utils": "2.0.0-dev.4.1.0.148229",
55
+ "@fluidframework/synthesize": "2.0.0-dev.4.1.0.148229",
56
+ "@fluidframework/view-interfaces": "2.0.0-dev.4.1.0.148229",
83
57
  "uuid": "^8.3.1"
84
58
  },
85
59
  "devDependencies": {
86
- "@fluid-tools/build-cli": "^0.7.0",
87
- "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.0.0-internal.2.2.0",
60
+ "@fluid-tools/build-cli": "^0.13.1",
61
+ "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.0.0-internal.4.0.0",
88
62
  "@fluidframework/build-common": "^1.1.0",
89
- "@fluidframework/build-tools": "^0.7.0",
90
- "@fluidframework/eslint-config-fluid": "^1.2.0",
91
- "@fluidframework/mocha-test-setup": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
92
- "@microsoft/api-extractor": "^7.22.2",
93
- "@rushstack/eslint-config": "^2.5.1",
63
+ "@fluidframework/build-tools": "^0.13.1",
64
+ "@fluidframework/eslint-config-fluid": "^2.0.0",
65
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.4.1.0.148229",
66
+ "@microsoft/api-extractor": "^7.34.4",
94
67
  "@types/mocha": "^9.1.1",
95
- "@types/node": "^14.18.0",
96
- "concurrently": "^6.2.0",
68
+ "@types/node": "^14.18.38",
69
+ "concurrently": "^7.6.0",
97
70
  "copyfiles": "^2.4.1",
98
- "cross-env": "^7.0.2",
71
+ "cross-env": "^7.0.3",
99
72
  "eslint": "~8.6.0",
100
- "mocha": "^10.0.0",
101
- "nyc": "^15.0.0",
73
+ "mocha": "^10.2.0",
74
+ "mocha-json-output-reporter": "^2.0.1",
75
+ "mocha-multi-reporters": "^1.5.1",
76
+ "moment": "^2.21.0",
77
+ "nyc": "^15.1.0",
102
78
  "prettier": "~2.6.2",
103
- "rimraf": "^2.6.2",
79
+ "rimraf": "^4.4.0",
104
80
  "typescript": "~4.5.5"
105
81
  },
106
82
  "module:es5": "es5/index.js",
107
83
  "typeValidation": {
108
- "version": "2.0.0-internal.2.3.0",
109
- "baselineRange": ">=2.0.0-internal.2.2.0 <2.0.0-internal.2.3.0",
110
- "baselineVersion": "2.0.0-internal.2.2.0",
111
84
  "broken": {}
85
+ },
86
+ "scripts": {
87
+ "build": "concurrently npm:build:compile npm:lint && npm run build:docs",
88
+ "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
89
+ "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
90
+ "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
91
+ "build:esnext": "tsc --project ./tsconfig.esnext.json",
92
+ "build:full": "npm run build",
93
+ "build:full:compile": "npm run build:compile",
94
+ "build:test": "tsc --project ./src/test/tsconfig.json",
95
+ "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
96
+ "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
97
+ "eslint": "eslint --format stylish src",
98
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
99
+ "format": "npm run prettier:fix",
100
+ "lint": "npm run prettier && npm run eslint",
101
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
102
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
103
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
104
+ "test": "npm run test:mocha",
105
+ "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
106
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
107
+ "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
108
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
109
+ "tsc": "tsc",
110
+ "typetests:gen": "fluid-type-test-generator",
111
+ "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
112
112
  }
113
- }
113
+ }
@@ -1,27 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IResponse, IFluidRouter, IRequest, FluidObject } from "@fluidframework/core-interfaces";
6
- import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
7
- import { RuntimeRequestHandler } from "@fluidframework/request-handler";
8
- export declare const serviceRoutePathRoot = "_services";
9
- export declare type ContainerServiceRegistryEntries = Iterable<[
10
- string,
11
- (runtime: IContainerRuntime) => Promise<FluidObject>
12
- ]>;
13
- /**
14
- * This class is a simple starter class for building a Container Service. It simply provides routing
15
- */
16
- export declare abstract class BaseContainerService implements IFluidRouter {
17
- protected readonly runtime: IContainerRuntime;
18
- get IFluidRouter(): this;
19
- constructor(runtime: IContainerRuntime);
20
- request(request: IRequest): Promise<IResponse>;
21
- }
22
- /**
23
- * Given a collection of IContainerServices will produce a RequestHandler for them all
24
- * @param serviceRegistry - Collection of Container Services
25
- */
26
- export declare const generateContainerServicesRequestHandler: (serviceRegistry: ContainerServiceRegistryEntries) => RuntimeRequestHandler;
27
- //# sourceMappingURL=containerServices.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"containerServices.d.ts","sourceRoot":"","sources":["../../src/container-services/containerServices.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAQxE,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,oBAAY,+BAA+B,GAAG,QAAQ,CAAC;IAAC,MAAM;IAAE,CAAC,OAAO,EAAE,iBAAiB,KACvF,OAAO,CAAC,WAAW,CAAC;CAAC,CAAC,CAAC;AAE3B;;GAEG;AACH,8BAAsB,oBAAqB,YAAW,YAAY;IAGlD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,iBAAiB;IAFzD,IAAW,YAAY,SAAmB;gBAEX,OAAO,EAAE,iBAAiB;IAG5C,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CAO9D;AAoBD;;;GAGG;AACH,eAAO,MAAM,uCAAuC,wDACI,qBA0CnD,CAAC"}
@@ -1,84 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.generateContainerServicesRequestHandler = exports.BaseContainerService = exports.serviceRoutePathRoot = void 0;
8
- const runtime_utils_1 = require("@fluidframework/runtime-utils");
9
- // TODO: should this just be "s"?
10
- exports.serviceRoutePathRoot = "_services";
11
- /**
12
- * This class is a simple starter class for building a Container Service. It simply provides routing
13
- */
14
- class BaseContainerService {
15
- constructor(runtime) {
16
- this.runtime = runtime;
17
- }
18
- get IFluidRouter() { return this; }
19
- async request(request) {
20
- return {
21
- status: 200,
22
- mimeType: "fluid/object",
23
- value: this,
24
- };
25
- }
26
- }
27
- exports.BaseContainerService = BaseContainerService;
28
- /**
29
- * ContainerService Factory that will only create one instance of the service for the Container.
30
- */
31
- class SingletonContainerServiceFactory {
32
- constructor(serviceFn) {
33
- this.serviceFn = serviceFn;
34
- }
35
- async getService(runtime) {
36
- if (!this.service) {
37
- this.service = this.serviceFn(runtime);
38
- }
39
- return this.service;
40
- }
41
- }
42
- /**
43
- * Given a collection of IContainerServices will produce a RequestHandler for them all
44
- * @param serviceRegistry - Collection of Container Services
45
- */
46
- const generateContainerServicesRequestHandler = (serviceRegistry) => {
47
- const factories = new Map();
48
- new Map(serviceRegistry).forEach((fn, id) => {
49
- factories.set(id, new SingletonContainerServiceFactory(fn));
50
- });
51
- return async (request, runtime) => {
52
- if (request.pathParts[0] !== exports.serviceRoutePathRoot) {
53
- // If the request is not for a service we return undefined so the next handler can use it
54
- return undefined;
55
- }
56
- if (request.pathParts.length < 2) {
57
- // If there is not service to route to then return a failure
58
- return (0, runtime_utils_1.createResponseError)(400, "request did not specify a service to route to", request);
59
- }
60
- const factory = factories.get(request.pathParts[1]);
61
- if (!factory) {
62
- // If we can't find a registry entry then return
63
- return (0, runtime_utils_1.create404Response)(request);
64
- }
65
- const service = await factory.getService(runtime);
66
- const router = service.IFluidRouter;
67
- const subRequest = request.createSubRequest(2);
68
- if (router) {
69
- return router.request(subRequest);
70
- }
71
- if (!request.isLeaf(2)) {
72
- // If there is not terminating route but a sub-route was requested then we will fail.
73
- return (0, runtime_utils_1.createResponseError)(400, "request sub-url for service that doesn't support routing", request);
74
- }
75
- // Otherwise we will just return the service
76
- return {
77
- status: 200,
78
- mimeType: "fluid/object",
79
- value: service,
80
- };
81
- };
82
- };
83
- exports.generateContainerServicesRequestHandler = generateContainerServicesRequestHandler;
84
- //# sourceMappingURL=containerServices.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"containerServices.js","sourceRoot":"","sources":["../../src/container-services/containerServices.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,iEAIuC;AAEvC,iCAAiC;AACpB,QAAA,oBAAoB,GAAG,WAAW,CAAC;AAKhD;;GAE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AE,OAAO,CAAC,CAAC;SAC7F;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE;YACV,gDAAgD;YAChD,OAAO,IAAA,iCAAiB,EAAC,OAAO,CAAC,CAAC;SACrC;QAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,MAAM,EAAE;YACR,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SACrC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;YACpB,qFAAqF;YACrF,OAAO,IAAA,mCAAmB,EAAC,GAAG,EAAE,0DAA0D,EAAE,OAAO,CAAC,CAAC;SACxG;QAED,4CAA4C;QAC5C,OAAO;YACH,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,OAAO;SACjB,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAC;AA3CO,QAAA,uCAAuC,2CA2C9C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResponse, IFluidRouter, IRequest, FluidObject } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport {\n RequestParser,\n create404Response,\n createResponseError,\n} from \"@fluidframework/runtime-utils\";\n\n// TODO: should this just be \"s\"?\nexport const serviceRoutePathRoot = \"_services\";\n\nexport type ContainerServiceRegistryEntries = Iterable<[string, (runtime: IContainerRuntime) =>\n Promise<FluidObject>]>;\n\n/**\n * This class is a simple starter class for building a Container Service. It simply provides routing\n */\nexport abstract class BaseContainerService implements IFluidRouter {\n public get IFluidRouter() { return this; }\n\n constructor(protected readonly runtime: IContainerRuntime) {\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: this,\n };\n }\n}\n\n/**\n * ContainerService Factory that will only create one instance of the service for the Container.\n */\nclass SingletonContainerServiceFactory {\n private service: Promise<FluidObject> | undefined;\n\n public constructor(\n private readonly serviceFn: (runtime: IContainerRuntime) => Promise<FluidObject>,\n ) { }\n\n public async getService(runtime: IContainerRuntime): Promise<FluidObject<IFluidRouter>> {\n if (!this.service) {\n this.service = this.serviceFn(runtime);\n }\n return this.service;\n }\n}\n\n/**\n * Given a collection of IContainerServices will produce a RequestHandler for them all\n * @param serviceRegistry - Collection of Container Services\n */\nexport const generateContainerServicesRequestHandler =\n (serviceRegistry: ContainerServiceRegistryEntries): RuntimeRequestHandler => {\n const factories: Map<string, SingletonContainerServiceFactory> = new Map();\n new Map(serviceRegistry).forEach((fn, id) => {\n factories.set(id, new SingletonContainerServiceFactory(fn));\n });\n\n return async (request: RequestParser, runtime: IContainerRuntime) => {\n if (request.pathParts[0] !== serviceRoutePathRoot) {\n // If the request is not for a service we return undefined so the next handler can use it\n return undefined;\n }\n\n if (request.pathParts.length < 2) {\n // If there is not service to route to then return a failure\n return createResponseError(400, \"request did not specify a service to route to\", request);\n }\n\n const factory = factories.get(request.pathParts[1]);\n if (!factory) {\n // If we can't find a registry entry then return\n return create404Response(request);\n }\n\n const service = await factory.getService(runtime);\n const router = service.IFluidRouter;\n const subRequest = request.createSubRequest(2);\n if (router) {\n return router.request(subRequest);\n }\n\n if (!request.isLeaf(2)) {\n // If there is not terminating route but a sub-route was requested then we will fail.\n return createResponseError(400, \"request sub-url for service that doesn't support routing\", request);\n }\n\n // Otherwise we will just return the service\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: service,\n };\n };\n };\n"]}
@@ -1,6 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export { BaseContainerService, ContainerServiceRegistryEntries, generateContainerServicesRequestHandler, serviceRoutePathRoot, } from "./containerServices";
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/container-services/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,oBAAoB,EACpB,+BAA+B,EAC/B,uCAAuC,EACvC,oBAAoB,GACpB,MAAM,qBAAqB,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.serviceRoutePathRoot = exports.generateContainerServicesRequestHandler = exports.BaseContainerService = void 0;
8
- var containerServices_1 = require("./containerServices");
9
- Object.defineProperty(exports, "BaseContainerService", { enumerable: true, get: function () { return containerServices_1.BaseContainerService; } });
10
- Object.defineProperty(exports, "generateContainerServicesRequestHandler", { enumerable: true, get: function () { return containerServices_1.generateContainerServicesRequestHandler; } });
11
- Object.defineProperty(exports, "serviceRoutePathRoot", { enumerable: true, get: function () { return containerServices_1.serviceRoutePathRoot; } });
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container-services/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAK6B;AAJ5B,yHAAA,oBAAoB,OAAA;AAEpB,4IAAA,uCAAuC,OAAA;AACvC,yHAAA,oBAAoB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tBaseContainerService,\n\tContainerServiceRegistryEntries,\n\tgenerateContainerServicesRequestHandler,\n\tserviceRoutePathRoot,\n} from \"./containerServices\";\n"]}