@restorecommerce/facade 1.3.8 → 1.3.10
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/CHANGELOG.md +15 -0
- package/codegen/index.d.ts +12 -0
- package/codegen/index.js +43 -0
- package/dist/gql/index.d.ts +1 -0
- package/dist/gql/index.js +1 -0
- package/dist/gql/protos/federation.d.ts +6 -0
- package/dist/gql/protos/federation.js +46 -0
- package/dist/gql/protos/graphql.d.ts +11 -0
- package/dist/gql/protos/graphql.js +158 -0
- package/dist/gql/protos/index.d.ts +6 -0
- package/dist/gql/protos/index.js +6 -0
- package/dist/gql/protos/registry.d.ts +23 -0
- package/dist/gql/protos/registry.js +366 -0
- package/dist/gql/protos/resolvers.d.ts +9 -0
- package/dist/gql/protos/resolvers.js +487 -0
- package/dist/gql/protos/schema.d.ts +14 -0
- package/dist/gql/protos/schema.js +224 -0
- package/dist/gql/protos/stream-to-async-iterator.d.ts +50 -0
- package/dist/gql/protos/stream-to-async-iterator.js +190 -0
- package/dist/gql/protos/types.d.ts +96 -0
- package/dist/gql/protos/types.js +1 -0
- package/dist/gql/protos/utils.d.ts +18 -0
- package/dist/gql/protos/utils.js +133 -0
- package/dist/gql/types/AccessControlTypes.d.ts +6 -0
- package/dist/gql/types/AccessControlTypes.js +97 -0
- package/dist/gql/types/DateType.d.ts +2 -0
- package/dist/gql/types/DateType.js +29 -0
- package/dist/gql/types/FilterType.d.ts +2 -0
- package/dist/gql/types/FilterType.js +72 -0
- package/dist/gql/types/MetaType.d.ts +2 -0
- package/dist/gql/types/MetaType.js +25 -0
- package/dist/gql/types/ScopeType.d.ts +2 -0
- package/dist/gql/types/ScopeType.js +13 -0
- package/dist/gql/types/SortType.d.ts +3 -0
- package/dist/gql/types/SortType.js +30 -0
- package/dist/gql/types/StatusType.d.ts +2 -0
- package/dist/gql/types/StatusType.js +15 -0
- package/dist/gql/types/index.d.ts +7 -0
- package/dist/gql/types/index.js +7 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +315 -0
- package/dist/interfaces.d.ts +54 -0
- package/dist/interfaces.js +6 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/middlewares/index.js +1 -0
- package/dist/middlewares/req-res-logger/index.d.ts +14 -0
- package/dist/middlewares/req-res-logger/index.js +90 -0
- package/dist/modules/access-control/gql/federation.d.ts +2 -0
- package/dist/modules/access-control/gql/federation.js +13 -0
- package/dist/modules/access-control/gql/schema.d.ts +2 -0
- package/dist/modules/access-control/gql/schema.generated.d.ts +1147 -0
- package/dist/modules/access-control/gql/schema.generated.js +80 -0
- package/dist/modules/access-control/gql/schema.js +5 -0
- package/dist/modules/access-control/gql/types.d.ts +3 -0
- package/dist/modules/access-control/gql/types.js +14 -0
- package/dist/modules/access-control/grpc/index.d.ts +13 -0
- package/dist/modules/access-control/grpc/index.js +14 -0
- package/dist/modules/access-control/index.d.ts +2 -0
- package/dist/modules/access-control/index.js +26 -0
- package/dist/modules/access-control/interfaces.d.ts +15 -0
- package/dist/modules/access-control/interfaces.js +1 -0
- package/dist/modules/catalog/gql/federation.d.ts +2 -0
- package/dist/modules/catalog/gql/federation.js +13 -0
- package/dist/modules/catalog/gql/schema.d.ts +2 -0
- package/dist/modules/catalog/gql/schema.generated.d.ts +1981 -0
- package/dist/modules/catalog/gql/schema.generated.js +74 -0
- package/dist/modules/catalog/gql/schema.js +5 -0
- package/dist/modules/catalog/gql/types.d.ts +3 -0
- package/dist/modules/catalog/gql/types.js +16 -0
- package/dist/modules/catalog/grpc/index.d.ts +15 -0
- package/dist/modules/catalog/grpc/index.js +16 -0
- package/dist/modules/catalog/index.d.ts +2 -0
- package/dist/modules/catalog/index.js +26 -0
- package/dist/modules/catalog/interfaces.d.ts +16 -0
- package/dist/modules/catalog/interfaces.js +1 -0
- package/dist/modules/facade-status/gql/index.d.ts +1 -0
- package/dist/modules/facade-status/gql/index.js +11 -0
- package/dist/modules/facade-status/gql/resolvers.d.ts +2 -0
- package/dist/modules/facade-status/gql/resolvers.js +18 -0
- package/dist/modules/facade-status/gql/schema.d.ts +3 -0
- package/dist/modules/facade-status/gql/schema.generated.d.ts +109 -0
- package/dist/modules/facade-status/gql/schema.generated.js +1 -0
- package/dist/modules/facade-status/gql/schema.js +14 -0
- package/dist/modules/facade-status/gql/types.d.ts +2 -0
- package/dist/modules/facade-status/gql/types.js +10 -0
- package/dist/modules/facade-status/index.d.ts +2 -0
- package/dist/modules/facade-status/index.js +8 -0
- package/dist/modules/facade-status/interfaces.d.ts +4 -0
- package/dist/modules/facade-status/interfaces.js +1 -0
- package/dist/modules/fulfillment/gql/federation.d.ts +2 -0
- package/dist/modules/fulfillment/gql/federation.js +13 -0
- package/dist/modules/fulfillment/gql/schema.d.ts +2 -0
- package/dist/modules/fulfillment/gql/schema.generated.d.ts +2729 -0
- package/dist/modules/fulfillment/gql/schema.generated.js +97 -0
- package/dist/modules/fulfillment/gql/schema.js +5 -0
- package/dist/modules/fulfillment/gql/types.d.ts +3 -0
- package/dist/modules/fulfillment/gql/types.js +12 -0
- package/dist/modules/fulfillment/grpc/index.d.ts +9 -0
- package/dist/modules/fulfillment/grpc/index.js +10 -0
- package/dist/modules/fulfillment/index.d.ts +2 -0
- package/dist/modules/fulfillment/index.js +26 -0
- package/dist/modules/fulfillment/interfaces.d.ts +16 -0
- package/dist/modules/fulfillment/interfaces.js +1 -0
- package/dist/modules/identity/api-key/api-key.d.ts +11 -0
- package/dist/modules/identity/api-key/api-key.js +137 -0
- package/dist/modules/identity/gql/federation.d.ts +2 -0
- package/dist/modules/identity/gql/federation.js +5 -0
- package/dist/modules/identity/gql/schema.d.ts +2 -0
- package/dist/modules/identity/gql/schema.generated.d.ts +1686 -0
- package/dist/modules/identity/gql/schema.generated.js +75 -0
- package/dist/modules/identity/gql/schema.js +5 -0
- package/dist/modules/identity/gql/types.d.ts +3 -0
- package/dist/modules/identity/gql/types.js +18 -0
- package/dist/modules/identity/grpc/index.d.ts +15 -0
- package/dist/modules/identity/grpc/index.js +16 -0
- package/dist/modules/identity/index.d.ts +4 -0
- package/dist/modules/identity/index.js +54 -0
- package/dist/modules/identity/interfaces.d.ts +22 -0
- package/dist/modules/identity/interfaces.js +1 -0
- package/dist/modules/identity/oauth/oauth.d.ts +11 -0
- package/dist/modules/identity/oauth/oauth.js +170 -0
- package/dist/modules/identity/oidc/adapter.d.ts +4 -0
- package/dist/modules/identity/oidc/adapter.js +135 -0
- package/dist/modules/identity/oidc/in-memory-adapter.d.ts +16 -0
- package/dist/modules/identity/oidc/in-memory-adapter.js +85 -0
- package/dist/modules/identity/oidc/index.d.ts +18 -0
- package/dist/modules/identity/oidc/index.js +147 -0
- package/dist/modules/identity/oidc/interfaces.d.ts +73 -0
- package/dist/modules/identity/oidc/interfaces.js +7 -0
- package/dist/modules/identity/oidc/password-grant.d.ts +2 -0
- package/dist/modules/identity/oidc/password-grant.js +163 -0
- package/dist/modules/identity/oidc/router.d.ts +13 -0
- package/dist/modules/identity/oidc/router.js +164 -0
- package/dist/modules/identity/oidc/templates.d.ts +36 -0
- package/dist/modules/identity/oidc/templates.js +60 -0
- package/dist/modules/identity/oidc/user.d.ts +6 -0
- package/dist/modules/identity/oidc/user.js +91 -0
- package/dist/modules/identity/oidc/utils.d.ts +6 -0
- package/dist/modules/identity/oidc/utils.js +15 -0
- package/dist/modules/index.d.ts +13 -0
- package/dist/modules/index.js +13 -0
- package/dist/modules/indexing/gql/federation.d.ts +2 -0
- package/dist/modules/indexing/gql/federation.js +13 -0
- package/dist/modules/indexing/gql/schema.d.ts +2 -0
- package/dist/modules/indexing/gql/schema.generated.d.ts +231 -0
- package/dist/modules/indexing/gql/schema.generated.js +6 -0
- package/dist/modules/indexing/gql/schema.js +5 -0
- package/dist/modules/indexing/gql/types.d.ts +3 -0
- package/dist/modules/indexing/gql/types.js +8 -0
- package/dist/modules/indexing/grpc/index.d.ts +7 -0
- package/dist/modules/indexing/grpc/index.js +8 -0
- package/dist/modules/indexing/index.d.ts +2 -0
- package/dist/modules/indexing/index.js +26 -0
- package/dist/modules/indexing/interfaces.d.ts +13 -0
- package/dist/modules/indexing/interfaces.js +1 -0
- package/dist/modules/invoicing/gql/federation.d.ts +2 -0
- package/dist/modules/invoicing/gql/federation.js +13 -0
- package/dist/modules/invoicing/gql/schema.d.ts +2 -0
- package/dist/modules/invoicing/gql/schema.generated.d.ts +2196 -0
- package/dist/modules/invoicing/gql/schema.generated.js +86 -0
- package/dist/modules/invoicing/gql/schema.js +5 -0
- package/dist/modules/invoicing/gql/types.d.ts +3 -0
- package/dist/modules/invoicing/gql/types.js +8 -0
- package/dist/modules/invoicing/grpc/index.d.ts +7 -0
- package/dist/modules/invoicing/grpc/index.js +8 -0
- package/dist/modules/invoicing/index.d.ts +2 -0
- package/dist/modules/invoicing/index.js +26 -0
- package/dist/modules/invoicing/interfaces.d.ts +16 -0
- package/dist/modules/invoicing/interfaces.js +1 -0
- package/dist/modules/master_data/gql/federation.d.ts +2 -0
- package/dist/modules/master_data/gql/federation.js +13 -0
- package/dist/modules/master_data/gql/schema.d.ts +2 -0
- package/dist/modules/master_data/gql/schema.generated.d.ts +2510 -0
- package/dist/modules/master_data/gql/schema.generated.js +109 -0
- package/dist/modules/master_data/gql/schema.js +5 -0
- package/dist/modules/master_data/gql/types.d.ts +3 -0
- package/dist/modules/master_data/gql/types.js +32 -0
- package/dist/modules/master_data/grpc/index.d.ts +30 -0
- package/dist/modules/master_data/grpc/index.js +32 -0
- package/dist/modules/master_data/index.d.ts +2 -0
- package/dist/modules/master_data/index.js +26 -0
- package/dist/modules/master_data/interfaces.d.ts +16 -0
- package/dist/modules/master_data/interfaces.js +1 -0
- package/dist/modules/notification/gql/federation.d.ts +2 -0
- package/dist/modules/notification/gql/federation.js +13 -0
- package/dist/modules/notification/gql/schema.d.ts +2 -0
- package/dist/modules/notification/gql/schema.generated.d.ts +655 -0
- package/dist/modules/notification/gql/schema.generated.js +68 -0
- package/dist/modules/notification/gql/schema.js +5 -0
- package/dist/modules/notification/gql/types.d.ts +3 -0
- package/dist/modules/notification/gql/types.js +8 -0
- package/dist/modules/notification/grpc/index.d.ts +7 -0
- package/dist/modules/notification/grpc/index.js +8 -0
- package/dist/modules/notification/index.d.ts +2 -0
- package/dist/modules/notification/index.js +26 -0
- package/dist/modules/notification/interfaces.d.ts +16 -0
- package/dist/modules/notification/interfaces.js +1 -0
- package/dist/modules/ordering/gql/federation.d.ts +2 -0
- package/dist/modules/ordering/gql/federation.js +13 -0
- package/dist/modules/ordering/gql/schema.d.ts +2 -0
- package/dist/modules/ordering/gql/schema.generated.d.ts +2599 -0
- package/dist/modules/ordering/gql/schema.generated.js +113 -0
- package/dist/modules/ordering/gql/schema.js +5 -0
- package/dist/modules/ordering/gql/types.d.ts +3 -0
- package/dist/modules/ordering/gql/types.js +8 -0
- package/dist/modules/ordering/grpc/index.d.ts +7 -0
- package/dist/modules/ordering/grpc/index.js +8 -0
- package/dist/modules/ordering/index.d.ts +2 -0
- package/dist/modules/ordering/index.js +26 -0
- package/dist/modules/ordering/interfaces.d.ts +16 -0
- package/dist/modules/ordering/interfaces.js +1 -0
- package/dist/modules/ostorage/gql/federation.d.ts +2 -0
- package/dist/modules/ostorage/gql/federation.js +13 -0
- package/dist/modules/ostorage/gql/schema.d.ts +2 -0
- package/dist/modules/ostorage/gql/schema.generated.d.ts +869 -0
- package/dist/modules/ostorage/gql/schema.generated.js +31 -0
- package/dist/modules/ostorage/gql/schema.js +5 -0
- package/dist/modules/ostorage/gql/types.d.ts +3 -0
- package/dist/modules/ostorage/gql/types.js +8 -0
- package/dist/modules/ostorage/grpc/index.d.ts +7 -0
- package/dist/modules/ostorage/grpc/index.js +8 -0
- package/dist/modules/ostorage/index.d.ts +2 -0
- package/dist/modules/ostorage/index.js +46 -0
- package/dist/modules/ostorage/interfaces.d.ts +16 -0
- package/dist/modules/ostorage/interfaces.js +1 -0
- package/dist/modules/ostorage/objectDownloadReqHandler.d.ts +1 -0
- package/dist/modules/ostorage/objectDownloadReqHandler.js +133 -0
- package/dist/modules/payment/gql/federation.d.ts +2 -0
- package/dist/modules/payment/gql/federation.js +13 -0
- package/dist/modules/payment/gql/schema.d.ts +2 -0
- package/dist/modules/payment/gql/schema.generated.d.ts +647 -0
- package/dist/modules/payment/gql/schema.generated.js +156 -0
- package/dist/modules/payment/gql/schema.js +5 -0
- package/dist/modules/payment/gql/types.d.ts +3 -0
- package/dist/modules/payment/gql/types.js +8 -0
- package/dist/modules/payment/grpc/index.d.ts +7 -0
- package/dist/modules/payment/grpc/index.js +8 -0
- package/dist/modules/payment/index.d.ts +2 -0
- package/dist/modules/payment/index.js +26 -0
- package/dist/modules/payment/interfaces.d.ts +16 -0
- package/dist/modules/payment/interfaces.js +1 -0
- package/dist/modules/scheduling/gql/federation.d.ts +2 -0
- package/dist/modules/scheduling/gql/federation.js +13 -0
- package/dist/modules/scheduling/gql/schema.d.ts +2 -0
- package/dist/modules/scheduling/gql/schema.generated.d.ts +651 -0
- package/dist/modules/scheduling/gql/schema.generated.js +31 -0
- package/dist/modules/scheduling/gql/schema.js +5 -0
- package/dist/modules/scheduling/gql/types.d.ts +3 -0
- package/dist/modules/scheduling/gql/types.js +8 -0
- package/dist/modules/scheduling/grpc/index.d.ts +7 -0
- package/dist/modules/scheduling/grpc/index.js +8 -0
- package/dist/modules/scheduling/index.d.ts +2 -0
- package/dist/modules/scheduling/index.js +26 -0
- package/dist/modules/scheduling/interfaces.d.ts +16 -0
- package/dist/modules/scheduling/interfaces.js +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +14 -0
- package/package.json +9 -8
- package/tsconfig-base.json +19 -8
- package/tsconfig.codegen.json +1 -0
- package/tsconfig.debug.json +5 -1
- package/tsconfig.generate.json +3 -0
- package/tsconfig.lib.json +2 -1
- package/tsconfig.test.json +22 -1
- package/codegen/tsconfig.codegen.tsbuildinfo +0 -1
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
@@ -0,0 +1,31 @@
|
|
1
|
+
export var IoRestorecommerceFilterFilterOperation;
|
2
|
+
(function (IoRestorecommerceFilterFilterOperation) {
|
3
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["Eq"] = 0] = "Eq";
|
4
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["Lt"] = 1] = "Lt";
|
5
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["Lte"] = 2] = "Lte";
|
6
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["Gt"] = 3] = "Gt";
|
7
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["Gte"] = 4] = "Gte";
|
8
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["IsEmpty"] = 5] = "IsEmpty";
|
9
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["ILike"] = 6] = "ILike";
|
10
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["In"] = 7] = "In";
|
11
|
+
IoRestorecommerceFilterFilterOperation[IoRestorecommerceFilterFilterOperation["Neq"] = 8] = "Neq";
|
12
|
+
})(IoRestorecommerceFilterFilterOperation || (IoRestorecommerceFilterFilterOperation = {}));
|
13
|
+
export var IoRestorecommerceFilterFilterValueType;
|
14
|
+
(function (IoRestorecommerceFilterFilterValueType) {
|
15
|
+
IoRestorecommerceFilterFilterValueType[IoRestorecommerceFilterFilterValueType["String"] = 0] = "String";
|
16
|
+
IoRestorecommerceFilterFilterValueType[IoRestorecommerceFilterFilterValueType["Number"] = 1] = "Number";
|
17
|
+
IoRestorecommerceFilterFilterValueType[IoRestorecommerceFilterFilterValueType["Boolean"] = 2] = "Boolean";
|
18
|
+
IoRestorecommerceFilterFilterValueType[IoRestorecommerceFilterFilterValueType["Date"] = 3] = "Date";
|
19
|
+
IoRestorecommerceFilterFilterValueType[IoRestorecommerceFilterFilterValueType["Array"] = 4] = "Array";
|
20
|
+
})(IoRestorecommerceFilterFilterValueType || (IoRestorecommerceFilterFilterValueType = {}));
|
21
|
+
export var IoRestorecommerceFilterFilterOpOperator;
|
22
|
+
(function (IoRestorecommerceFilterFilterOpOperator) {
|
23
|
+
IoRestorecommerceFilterFilterOpOperator[IoRestorecommerceFilterFilterOpOperator["And"] = 0] = "And";
|
24
|
+
IoRestorecommerceFilterFilterOpOperator[IoRestorecommerceFilterFilterOpOperator["Or"] = 1] = "Or";
|
25
|
+
})(IoRestorecommerceFilterFilterOpOperator || (IoRestorecommerceFilterFilterOpOperator = {}));
|
26
|
+
export var SubscriptionAction;
|
27
|
+
(function (SubscriptionAction) {
|
28
|
+
SubscriptionAction["Created"] = "CREATED";
|
29
|
+
SubscriptionAction["Updated"] = "UPDATED";
|
30
|
+
SubscriptionAction["Deleted"] = "DELETED";
|
31
|
+
})(SubscriptionAction || (SubscriptionAction = {}));
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { registerTypings, subServices } from './types.js';
|
2
|
+
import { generateSubServiceSchemas, } from '../../../gql/protos/index.js';
|
3
|
+
import { namespace } from '../interfaces.js';
|
4
|
+
registerTypings();
|
5
|
+
export const schema = (cfg) => generateSubServiceSchemas(subServices, cfg, namespace, 'Ostorage');
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { protoMetadata as metaPackageIoRestorecommerceOstorage } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/ostorage.js';
|
2
|
+
import { registerPackagesRecursive } from '../../../gql/protos/index.js';
|
3
|
+
export const subServices = [
|
4
|
+
metaPackageIoRestorecommerceOstorage
|
5
|
+
];
|
6
|
+
export const registerTypings = () => {
|
7
|
+
registerPackagesRecursive(...subServices);
|
8
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { type ObjectServiceClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/ostorage.js';
|
3
|
+
import { type GrpcClientConfig } from '@restorecommerce/grpc-client';
|
4
|
+
export declare class OstorageSrvGrpcClient extends RestoreCommerceGrpcClient {
|
5
|
+
readonly ostorage: ObjectServiceClient;
|
6
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
7
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ObjectServiceDefinition } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/ostorage.js';
|
3
|
+
export class OstorageSrvGrpcClient extends RestoreCommerceGrpcClient {
|
4
|
+
constructor(address, cfg) {
|
5
|
+
super(address, cfg);
|
6
|
+
this.ostorage = this.createClient(cfg, ObjectServiceDefinition, this.channel);
|
7
|
+
}
|
8
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import { FederatedOstorageSchema } from './gql/federation.js';
|
11
|
+
import { namespace } from "./interfaces.js";
|
12
|
+
import { OstorageSrvGrpcClient } from "./grpc/index.js";
|
13
|
+
import { createFacadeModuleFactory } from "../../utils.js";
|
14
|
+
import { handleGetFile } from './objectDownloadReqHandler.js';
|
15
|
+
import Router from 'koa-router';
|
16
|
+
import bodyParser from 'koa-bodyparser';
|
17
|
+
export const ostorageModule = createFacadeModuleFactory(namespace, (facade, config) => {
|
18
|
+
const ostorage = {
|
19
|
+
client: new OstorageSrvGrpcClient(config.config.client.address, Object.assign(Object.assign({}, config.config.client), { logger: facade.logger }))
|
20
|
+
};
|
21
|
+
facade.addApolloService({
|
22
|
+
name: namespace,
|
23
|
+
schema: FederatedOstorageSchema(config.config)
|
24
|
+
});
|
25
|
+
const router = new Router();
|
26
|
+
router.use(bodyParser());
|
27
|
+
router.get(/^\/storage\/([^/]+)\/(.+)/, (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
28
|
+
const authToken = ctx.request.header['authorization'];
|
29
|
+
let token;
|
30
|
+
if (authToken && authToken.startsWith('Bearer ')) {
|
31
|
+
token = authToken.split(' ')[1];
|
32
|
+
ctx.subject = { token };
|
33
|
+
ctx.subject = { token };
|
34
|
+
}
|
35
|
+
const bucket = ctx.params[0];
|
36
|
+
const key = ctx.params[1];
|
37
|
+
yield handleGetFile(bucket, key, ctx, ostorage.client);
|
38
|
+
return ctx.response;
|
39
|
+
}));
|
40
|
+
facade.koa.use(router.routes());
|
41
|
+
facade.koa.use(router.allowedMethods());
|
42
|
+
facade.koa.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
43
|
+
ctx.ostorage = ostorage;
|
44
|
+
yield next();
|
45
|
+
}));
|
46
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { type OstorageSrvGrpcClient } from './grpc/index.js';
|
2
|
+
import { type FacadeModule, type FacadeContext } from '../../interfaces.js';
|
3
|
+
import { type ServiceConfig } from '../../gql/protos/index.js';
|
4
|
+
export interface OstorageServiceConfig extends ServiceConfig {
|
5
|
+
root: boolean;
|
6
|
+
}
|
7
|
+
export interface OstorageConfig {
|
8
|
+
config: OstorageServiceConfig;
|
9
|
+
}
|
10
|
+
export interface OstorageContext extends FacadeContext {
|
11
|
+
ostorage: {
|
12
|
+
client: OstorageSrvGrpcClient;
|
13
|
+
};
|
14
|
+
}
|
15
|
+
export type OstorageModule = FacadeModule<OstorageContext>;
|
16
|
+
export declare const namespace = "ostorage";
|
@@ -0,0 +1 @@
|
|
1
|
+
export const namespace = 'ostorage';
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const handleGetFile: (bucket: string, key: string, ctx: any, client: any) => Promise<any>;
|
@@ -0,0 +1,133 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import { createServiceConfig } from '@restorecommerce/service-config';
|
11
|
+
import { createLogger } from '@restorecommerce/logger';
|
12
|
+
import { isNumber } from 'util';
|
13
|
+
import intoStream from 'into-stream';
|
14
|
+
import { Transform } from 'stream';
|
15
|
+
import pkg from 'lodash';
|
16
|
+
const { isEmpty } = pkg;
|
17
|
+
const cfg = createServiceConfig(process.cwd());
|
18
|
+
const loggerCfg = cfg.get('logger');
|
19
|
+
let logger = createLogger(loggerCfg);
|
20
|
+
const dlQueryParamExist = (ctx) => {
|
21
|
+
// check if URL contains query parameter 'dl'
|
22
|
+
let filePath, hostName;
|
23
|
+
if (ctx && ctx.request && ctx.request.url) {
|
24
|
+
filePath = ctx.request.url;
|
25
|
+
}
|
26
|
+
if (ctx && ctx.request && ctx.request.header
|
27
|
+
&& ctx.request.header.host) {
|
28
|
+
hostName = ctx.request.header.host;
|
29
|
+
}
|
30
|
+
const completeUrl = 'http://' + hostName + filePath;
|
31
|
+
const reqURL = new URL(completeUrl);
|
32
|
+
return reqURL.searchParams.has('dl');
|
33
|
+
};
|
34
|
+
export const handleGetFile = (bucket, key, ctx, client) => __awaiter(void 0, void 0, void 0, function* () {
|
35
|
+
try {
|
36
|
+
let download = false;
|
37
|
+
download = dlQueryParamExist(ctx);
|
38
|
+
// get the target orgKey from the ostorage meta and set it before making ACS request
|
39
|
+
let req = { bucket, key, download };
|
40
|
+
logger.debug('Received download request', { bucket, key });
|
41
|
+
const ostorageSrv = client['ostorage'];
|
42
|
+
req = { bucket, key, download, subject: ctx.subject };
|
43
|
+
let grpcGetStream = yield ostorageSrv.get(req);
|
44
|
+
const readStream = intoStream.object(grpcGetStream);
|
45
|
+
let streamData = {
|
46
|
+
key: '', object: {}, url: '', options: {}
|
47
|
+
};
|
48
|
+
readStream.on('error', (err) => {
|
49
|
+
if (err.message.includes('NotFound')) {
|
50
|
+
err.code = 404;
|
51
|
+
}
|
52
|
+
else if (err.message.includes('PermissionDenied')) {
|
53
|
+
err.code = 403;
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
err.code = 500;
|
57
|
+
}
|
58
|
+
ctx.response.status = err.code;
|
59
|
+
logger.error('Error streaming request', { message: err.message });
|
60
|
+
ctx.res.end(err.message);
|
61
|
+
});
|
62
|
+
readStream.on('end', (data) => {
|
63
|
+
ctx.response.status = 200;
|
64
|
+
logger.info(`File ${key} download completed successfully from bucket ${bucket}`);
|
65
|
+
});
|
66
|
+
const transformGrpcObjToBuffer = () => {
|
67
|
+
return new Transform({
|
68
|
+
objectMode: true,
|
69
|
+
transform: (chunk, _, done) => {
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
71
|
+
// set options if its not set already
|
72
|
+
if (isEmpty(streamData.options)) {
|
73
|
+
streamData.options = (_b = (_a = chunk.response) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.options;
|
74
|
+
// set Last-Modified
|
75
|
+
if ((_e = (_d = (_c = chunk === null || chunk === void 0 ? void 0 : chunk.response) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.meta) === null || _e === void 0 ? void 0 : _e.modified) {
|
76
|
+
ctx.response.set('Last-Modified', new Date((_h = (_g = (_f = chunk === null || chunk === void 0 ? void 0 : chunk.response) === null || _f === void 0 ? void 0 : _f.payload) === null || _g === void 0 ? void 0 : _g.meta) === null || _h === void 0 ? void 0 : _h.modified));
|
77
|
+
}
|
78
|
+
if (!streamData.options) {
|
79
|
+
logger.silly(`File ${key} from bucket ${bucket} does have empty options`, streamData.options);
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
// set response headers on ctx response received from ostorage-srv
|
83
|
+
let { encoding, content_type, content_language, content_disposition, length, version, md5 } = streamData.options;
|
84
|
+
if (encoding) {
|
85
|
+
ctx.response.set('Content-Encoding', encoding);
|
86
|
+
}
|
87
|
+
if (content_type) {
|
88
|
+
ctx.response.set('Content-Type', content_type);
|
89
|
+
}
|
90
|
+
if (content_language) {
|
91
|
+
ctx.response.set('Content-Language', content_language);
|
92
|
+
}
|
93
|
+
const name = streamData.key;
|
94
|
+
if (content_disposition) {
|
95
|
+
ctx.response.set('Content-Disposition', `${content_disposition};filename=${name}`);
|
96
|
+
}
|
97
|
+
if (length) {
|
98
|
+
ctx.response.set('Content-Length', length);
|
99
|
+
}
|
100
|
+
if (version) {
|
101
|
+
ctx.response.set('ETag', version);
|
102
|
+
}
|
103
|
+
if (md5) {
|
104
|
+
ctx.response.set('Content-MD5', md5);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
// object buffer
|
109
|
+
if (((_k = (_j = chunk.response) === null || _j === void 0 ? void 0 : _j.status) === null || _k === void 0 ? void 0 : _k.code) && ((_l = chunk.response) === null || _l === void 0 ? void 0 : _l.status.code) != 200) {
|
110
|
+
ctx.response.status = chunk.response.status.code;
|
111
|
+
logger.error('Error streaming request', { message: chunk.response });
|
112
|
+
ctx.res.end(chunk.response.status.message);
|
113
|
+
}
|
114
|
+
done(null, (_o = (_m = chunk === null || chunk === void 0 ? void 0 : chunk.response) === null || _m === void 0 ? void 0 : _m.payload) === null || _o === void 0 ? void 0 : _o.object);
|
115
|
+
}
|
116
|
+
});
|
117
|
+
};
|
118
|
+
// assigning the grpcStream object through transform to Koa ctx response
|
119
|
+
ctx.response.body = readStream.pipe(transformGrpcObjToBuffer());
|
120
|
+
if (streamData.error && streamData.error.message) {
|
121
|
+
ctx.response.status = 404;
|
122
|
+
ctx.response.body = 'Object does not exist';
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
return ctx.response;
|
126
|
+
}
|
127
|
+
catch (error) {
|
128
|
+
logger.error(`Error downloading file ${key}`, { code: error.code, message: error.message, stack: error.stack });
|
129
|
+
ctx.response.body = error.message;
|
130
|
+
ctx.response.status = isNumber(error.code) ? error.code : 500;
|
131
|
+
return ctx.response;
|
132
|
+
}
|
133
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { gql } from 'graphql-tag';
|
2
|
+
import { buildSubgraphSchema } from '@apollo/federation';
|
3
|
+
import { schema } from './schema.js';
|
4
|
+
import { generateSubServiceResolvers } from '../../../gql/protos/index.js';
|
5
|
+
import { namespace } from '../interfaces.js';
|
6
|
+
import { subServices } from './types.js';
|
7
|
+
import { printSchema } from 'graphql';
|
8
|
+
// TODO There is currently no way of building a federated schema from GraphQLSchema Object
|
9
|
+
// See https://github.com/apollographql/apollo-server/pull/4310
|
10
|
+
export const FederatedPaymentSchema = (cfg) => buildSubgraphSchema({
|
11
|
+
typeDefs: gql(printSchema(schema(cfg))),
|
12
|
+
resolvers: generateSubServiceResolvers(subServices, cfg, namespace)
|
13
|
+
});
|