@mondomob/gae-node-nestjs 12.0.0-alpha-1 → 12.0.0-alpha-2
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/mondomob-gae-node-nestjs-12.0.0-alpha-1.tgz +0 -0
- package/mondomob-gae-node-nestjs-12.0.0-alpha-2.tgz +0 -0
- package/package.json +4 -4
- package/dist/_test/mocks.d.ts +0 -9
- package/dist/_test/mocks.js +0 -27
- package/dist/_test/mocks.js.map +0 -1
- package/dist/_test/request-scope-test-utils.d.ts +0 -3
- package/dist/_test/request-scope-test-utils.js +0 -18
- package/dist/_test/request-scope-test-utils.js.map +0 -1
- package/dist/auth/auth-user.model.d.ts +0 -9
- package/dist/auth/auth-user.model.js +0 -33
- package/dist/auth/auth-user.model.js.map +0 -1
- package/dist/auth/auth.callbacks.d.ts +0 -8
- package/dist/auth/auth.callbacks.js +0 -5
- package/dist/auth/auth.callbacks.js.map +0 -1
- package/dist/auth/auth.configurer.d.ts +0 -35
- package/dist/auth/auth.configurer.js +0 -212
- package/dist/auth/auth.configurer.js.map +0 -1
- package/dist/auth/auth.controller.d.ts +0 -27
- package/dist/auth/auth.controller.js +0 -312
- package/dist/auth/auth.controller.js.map +0 -1
- package/dist/auth/auth.guard.d.ts +0 -16
- package/dist/auth/auth.guard.js +0 -127
- package/dist/auth/auth.guard.js.map +0 -1
- package/dist/auth/auth.listener.d.ts +0 -5
- package/dist/auth/auth.listener.js +0 -5
- package/dist/auth/auth.listener.js.map +0 -1
- package/dist/auth/auth.repository.d.ts +0 -52
- package/dist/auth/auth.repository.js +0 -79
- package/dist/auth/auth.repository.js.map +0 -1
- package/dist/auth/auth.resolver.d.ts +0 -13
- package/dist/auth/auth.resolver.js +0 -86
- package/dist/auth/auth.resolver.js.map +0 -1
- package/dist/auth/auth.service.d.ts +0 -35
- package/dist/auth/auth.service.js +0 -299
- package/dist/auth/auth.service.js.map +0 -1
- package/dist/auth/auth.task.controller.d.ts +0 -13
- package/dist/auth/auth.task.controller.js +0 -76
- package/dist/auth/auth.task.controller.js.map +0 -1
- package/dist/auth/auth.task.service.d.ts +0 -8
- package/dist/auth/auth.task.service.js +0 -26
- package/dist/auth/auth.task.service.js.map +0 -1
- package/dist/auth/csrf.interceptor.d.ts +0 -11
- package/dist/auth/csrf.interceptor.js +0 -38
- package/dist/auth/csrf.interceptor.js.map +0 -1
- package/dist/auth/invite-user.service.d.ts +0 -45
- package/dist/auth/invite-user.service.js +0 -215
- package/dist/auth/invite-user.service.js.map +0 -1
- package/dist/auth/invite.callbacks.d.ts +0 -6
- package/dist/auth/invite.callbacks.js +0 -5
- package/dist/auth/invite.callbacks.js.map +0 -1
- package/dist/auth/login-identifier.repository.d.ts +0 -13
- package/dist/auth/login-identifier.repository.js +0 -28
- package/dist/auth/login-identifier.repository.js.map +0 -1
- package/dist/auth/password-reset.service.d.ts +0 -15
- package/dist/auth/password-reset.service.js +0 -81
- package/dist/auth/password-reset.service.js.map +0 -1
- package/dist/auth/user.service.d.ts +0 -27
- package/dist/auth/user.service.js +0 -94
- package/dist/auth/user.service.js.map +0 -1
- package/dist/configuration.d.ts +0 -84
- package/dist/configuration.js +0 -5
- package/dist/configuration.js.map +0 -1
- package/dist/configure.d.ts +0 -40
- package/dist/configure.js +0 -85
- package/dist/configure.js.map +0 -1
- package/dist/context/context-middleware.d.ts +0 -15
- package/dist/context/context-middleware.js +0 -37
- package/dist/context/context-middleware.js.map +0 -1
- package/dist/context/context-request-scope.d.ts +0 -8
- package/dist/context/context-request-scope.js +0 -29
- package/dist/context/context-request-scope.js.map +0 -1
- package/dist/context/index.d.ts +0 -2
- package/dist/context/index.js +0 -9
- package/dist/context/index.js.map +0 -1
- package/dist/datastore/context.d.ts +0 -36
- package/dist/datastore/context.js +0 -27
- package/dist/datastore/context.js.map +0 -1
- package/dist/datastore/datastore.provider.d.ts +0 -8
- package/dist/datastore/datastore.provider.js +0 -30
- package/dist/datastore/datastore.provider.js.map +0 -1
- package/dist/datastore/filters.d.ts +0 -19
- package/dist/datastore/filters.js +0 -27
- package/dist/datastore/filters.js.map +0 -1
- package/dist/datastore/loader.d.ts +0 -50
- package/dist/datastore/loader.js +0 -147
- package/dist/datastore/loader.js.map +0 -1
- package/dist/datastore/node-datastore-session.d.ts +0 -17
- package/dist/datastore/node-datastore-session.js +0 -87
- package/dist/datastore/node-datastore-session.js.map +0 -1
- package/dist/datastore/repository.d.ts +0 -45
- package/dist/datastore/repository.js +0 -150
- package/dist/datastore/repository.js.map +0 -1
- package/dist/datastore/transactional.d.ts +0 -4
- package/dist/datastore/transactional.js +0 -13
- package/dist/datastore/transactional.js.map +0 -1
- package/dist/error/NonFatalError.d.ts +0 -3
- package/dist/error/NonFatalError.js +0 -11
- package/dist/error/NonFatalError.js.map +0 -1
- package/dist/filter.d.ts +0 -5
- package/dist/filter.js +0 -40
- package/dist/filter.js.map +0 -1
- package/dist/gcloud/logging.d.ts +0 -1
- package/dist/gcloud/logging.js +0 -5
- package/dist/gcloud/logging.js.map +0 -1
- package/dist/gcloud/storage.provider.d.ts +0 -12
- package/dist/gcloud/storage.provider.js +0 -41
- package/dist/gcloud/storage.provider.js.map +0 -1
- package/dist/gcloud/tasks.d.ts +0 -10
- package/dist/gcloud/tasks.js +0 -68
- package/dist/gcloud/tasks.js.map +0 -1
- package/dist/graphql/GraphQLMiddleware.d.ts +0 -0
- package/dist/graphql/GraphQLMiddleware.js +0 -2
- package/dist/graphql/GraphQLMiddleware.js.map +0 -1
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -65
- package/dist/index.js.map +0 -1
- package/dist/logging/index.d.ts +0 -1
- package/dist/logging/index.js +0 -8
- package/dist/logging/index.js.map +0 -1
- package/dist/logging/logging-internal.d.ts +0 -2
- package/dist/logging/logging-internal.js +0 -20
- package/dist/logging/logging-internal.js.map +0 -1
- package/dist/logging/logging-request-scope.d.ts +0 -15
- package/dist/logging/logging-request-scope.js +0 -39
- package/dist/logging/logging-request-scope.js.map +0 -1
- package/dist/logging/logging.d.ts +0 -34
- package/dist/logging/logging.js +0 -55
- package/dist/logging/logging.js.map +0 -1
- package/dist/mail/gmail/gmail.configurer.d.ts +0 -15
- package/dist/mail/gmail/gmail.configurer.js +0 -59
- package/dist/mail/gmail/gmail.configurer.js.map +0 -1
- package/dist/mail/gmail/gmail.controller.d.ts +0 -9
- package/dist/mail/gmail/gmail.controller.js +0 -62
- package/dist/mail/gmail/gmail.controller.js.map +0 -1
- package/dist/mail/gmail/gmail.sender.d.ts +0 -12
- package/dist/mail/gmail/gmail.sender.js +0 -62
- package/dist/mail/gmail/gmail.sender.js.map +0 -1
- package/dist/mail/gmail/stored.credentials.repository.d.ts +0 -12
- package/dist/mail/gmail/stored.credentials.repository.js +0 -23
- package/dist/mail/gmail/stored.credentials.repository.js.map +0 -1
- package/dist/mail/mail-logging.sender.d.ts +0 -9
- package/dist/mail/mail-logging.sender.js +0 -42
- package/dist/mail/mail-logging.sender.js.map +0 -1
- package/dist/mail/mail-subject.sender.d.ts +0 -12
- package/dist/mail/mail-subject.sender.js +0 -33
- package/dist/mail/mail-subject.sender.js.map +0 -1
- package/dist/mail/mail-whitelist.sender.d.ts +0 -14
- package/dist/mail/mail-whitelist.sender.js +0 -59
- package/dist/mail/mail-whitelist.sender.js.map +0 -1
- package/dist/mail/mail.diverter.d.ts +0 -13
- package/dist/mail/mail.diverter.js +0 -65
- package/dist/mail/mail.diverter.js.map +0 -1
- package/dist/mail/mail.sender.d.ts +0 -6
- package/dist/mail/mail.sender.js +0 -5
- package/dist/mail/mail.sender.js.map +0 -1
- package/dist/mail/smtp/smtp.sender.d.ts +0 -10
- package/dist/mail/smtp/smtp.sender.js +0 -65
- package/dist/mail/smtp/smtp.sender.js.map +0 -1
- package/dist/mail-templates/base.d.ts +0 -2
- package/dist/mail-templates/base.js +0 -328
- package/dist/mail-templates/base.js.map +0 -1
- package/dist/mail-templates/invite.d.ts +0 -1
- package/dist/mail-templates/invite.js +0 -19
- package/dist/mail-templates/invite.js.map +0 -1
- package/dist/module.d.ts +0 -16
- package/dist/module.js +0 -136
- package/dist/module.js.map +0 -1
- package/dist/request-scope/index.d.ts +0 -2
- package/dist/request-scope/index.js +0 -9
- package/dist/request-scope/index.js.map +0 -1
- package/dist/request-scope/request-scope-interceptor.d.ts +0 -5
- package/dist/request-scope/request-scope-interceptor.js +0 -3
- package/dist/request-scope/request-scope-interceptor.js.map +0 -1
- package/dist/request-scope/request-scope.d.ts +0 -12
- package/dist/request-scope/request-scope.js +0 -79
- package/dist/request-scope/request-scope.js.map +0 -1
- package/dist/request-scope/request-scope.middleware.d.ts +0 -15
- package/dist/request-scope/request-scope.middleware.js +0 -53
- package/dist/request-scope/request-scope.middleware.js.map +0 -1
- package/dist/search/search.service.d.ts +0 -52
- package/dist/search/search.service.js +0 -90
- package/dist/search/search.service.js.map +0 -1
- package/dist/search/searchable.repository.d.ts +0 -36
- package/dist/search/searchable.repository.js +0 -95
- package/dist/search/searchable.repository.js.map +0 -1
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -9
- package/dist/types.js.map +0 -1
- package/dist/util/arrays.d.ts +0 -1
- package/dist/util/arrays.js +0 -10
- package/dist/util/arrays.js.map +0 -1
- package/dist/util/guards.d.ts +0 -1
- package/dist/util/guards.js +0 -7
- package/dist/util/guards.js.map +0 -1
- package/dist/util/index.d.ts +0 -1
- package/dist/util/index.js +0 -5
- package/dist/util/index.js.map +0 -1
- package/dist/util/nestjs.d.ts +0 -9
- package/dist/util/nestjs.js +0 -9
- package/dist/util/nestjs.js.map +0 -1
- package/dist/util/types.d.ts +0 -4
- package/dist/util/types.js +0 -8
- package/dist/util/types.js.map +0 -1
- package/dist/validator.d.ts +0 -1
- package/dist/validator.js +0 -5
- package/dist/validator.js.map +0 -1
package/dist/configuration.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
export interface Configuration {
|
|
2
|
-
isDevelopment(): boolean;
|
|
3
|
-
bucket: string;
|
|
4
|
-
environment: string;
|
|
5
|
-
projectId: string;
|
|
6
|
-
location: string;
|
|
7
|
-
host: string;
|
|
8
|
-
searchServiceEndpoint?: string;
|
|
9
|
-
apiEndpoint?: string;
|
|
10
|
-
gmailUser: string;
|
|
11
|
-
passwordTokenExpiry?: number;
|
|
12
|
-
systemSecret: Buffer;
|
|
13
|
-
serviceTasksOnThisVersion?: boolean;
|
|
14
|
-
requestScope?: {
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
logBundlingEnabled?: boolean;
|
|
17
|
-
};
|
|
18
|
-
auth: {
|
|
19
|
-
fake?: {
|
|
20
|
-
enabled?: boolean;
|
|
21
|
-
secret?: string;
|
|
22
|
-
};
|
|
23
|
-
local?: {
|
|
24
|
-
enabled?: boolean;
|
|
25
|
-
activationExpiryInMinutes?: number;
|
|
26
|
-
activationExpiryEmailCopy?: string;
|
|
27
|
-
invitationEmailCopy?: string;
|
|
28
|
-
};
|
|
29
|
-
google?: {
|
|
30
|
-
enabled?: boolean;
|
|
31
|
-
clientId: string;
|
|
32
|
-
secret: string;
|
|
33
|
-
signUpEnabled: boolean;
|
|
34
|
-
signUpDomains?: string[];
|
|
35
|
-
signUpRoles?: string[];
|
|
36
|
-
failureRedirect?: string;
|
|
37
|
-
};
|
|
38
|
-
saml?: {
|
|
39
|
-
enabled?: boolean;
|
|
40
|
-
cert: string;
|
|
41
|
-
identityProviderUrl: string;
|
|
42
|
-
failureRedirect?: string;
|
|
43
|
-
};
|
|
44
|
-
auth0?: {
|
|
45
|
-
enabled?: boolean;
|
|
46
|
-
domain: string;
|
|
47
|
-
clientId: string;
|
|
48
|
-
secret: string;
|
|
49
|
-
namespace: string;
|
|
50
|
-
failureRedirect?: string;
|
|
51
|
-
};
|
|
52
|
-
oidc?: {
|
|
53
|
-
enabled?: boolean;
|
|
54
|
-
issuer: string;
|
|
55
|
-
clientId: string;
|
|
56
|
-
secret: string;
|
|
57
|
-
authUrl: string;
|
|
58
|
-
userInfoUrl: string;
|
|
59
|
-
tokenUrl: string;
|
|
60
|
-
newUserRoles?: string[];
|
|
61
|
-
replaceAuth?: boolean;
|
|
62
|
-
failureRedirect?: string;
|
|
63
|
-
};
|
|
64
|
-
smtp?: {
|
|
65
|
-
enabled: boolean;
|
|
66
|
-
host: string;
|
|
67
|
-
port: number;
|
|
68
|
-
secure: boolean;
|
|
69
|
-
user: string;
|
|
70
|
-
password: string;
|
|
71
|
-
from: {
|
|
72
|
-
name: string;
|
|
73
|
-
address: string;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
devHooks?: {
|
|
78
|
-
disableLocalMailLogger?: boolean;
|
|
79
|
-
divertEmailTo?: string[];
|
|
80
|
-
emailWhitelist?: string[];
|
|
81
|
-
emailSubjectPrefix?: string;
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
export declare const CONFIGURATION = "Configuration";
|
package/dist/configuration.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;AAsFa,QAAA,aAAa,GAAG,eAAe,CAAC"}
|
package/dist/configure.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { OneOrMany } from './util/types';
|
|
2
|
-
import { ServeStaticOptions } from 'serve-static';
|
|
3
|
-
interface CookieOptions {
|
|
4
|
-
maxAge?: number;
|
|
5
|
-
signed?: boolean;
|
|
6
|
-
expires?: Date;
|
|
7
|
-
httpOnly?: boolean;
|
|
8
|
-
path?: string;
|
|
9
|
-
domain?: string;
|
|
10
|
-
secure?: boolean | 'auto';
|
|
11
|
-
encode?: (val: string) => string;
|
|
12
|
-
sameSite?: boolean | 'lax' | 'strict' | 'none';
|
|
13
|
-
}
|
|
14
|
-
interface ServerOptions {
|
|
15
|
-
csp?: object;
|
|
16
|
-
csrf?: {
|
|
17
|
-
ignorePaths?: OneOrMany<string | RegExp>;
|
|
18
|
-
sameSite?: boolean;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
};
|
|
21
|
-
session: {
|
|
22
|
-
secret: string;
|
|
23
|
-
projectId?: string;
|
|
24
|
-
apiEndpoint?: string;
|
|
25
|
-
cookie?: CookieOptions;
|
|
26
|
-
};
|
|
27
|
-
sessionTimeoutInMinutes?: number;
|
|
28
|
-
staticAssets?: {
|
|
29
|
-
options?: ServeStaticOptions;
|
|
30
|
-
prefix?: string;
|
|
31
|
-
root: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
interface Express {
|
|
35
|
-
use(...handlers: Function[]): void;
|
|
36
|
-
use(paths: OneOrMany<string | RegExp>, ...handlers: Function[]): void;
|
|
37
|
-
set(property: string, value: boolean): void;
|
|
38
|
-
}
|
|
39
|
-
export declare const configureExpress: (expressApp: Express, options: ServerOptions) => Promise<void>;
|
|
40
|
-
export {};
|
package/dist/configure.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configureExpress = void 0;
|
|
4
|
-
const node_datastore_session_1 = require("./datastore/node-datastore-session");
|
|
5
|
-
const datastore_1 = require("@google-cloud/datastore");
|
|
6
|
-
const express = require("express");
|
|
7
|
-
const session = require("express-session");
|
|
8
|
-
const csp = require("helmet-csp");
|
|
9
|
-
const passport = require("passport");
|
|
10
|
-
const csrf_interceptor_1 = require("./auth/csrf.interceptor");
|
|
11
|
-
const types_1 = require("./util/types");
|
|
12
|
-
const lb = require("@google-cloud/logging-bunyan");
|
|
13
|
-
const logging_internal_1 = require("./logging/logging-internal");
|
|
14
|
-
const minutesToMilliseconds = (minutes) => minutes * 60 * 1000;
|
|
15
|
-
const MAX_AGE_DEFAULT = minutesToMilliseconds(2 * 60);
|
|
16
|
-
const configureExpress = async (expressApp, options) => {
|
|
17
|
-
if (process.env.APP_ENGINE_ENVIRONMENT) {
|
|
18
|
-
const { mw } = await lb.express.middleware({ level: 'info' });
|
|
19
|
-
expressApp.use(mw);
|
|
20
|
-
}
|
|
21
|
-
expressApp.use(csp(options.csp || {
|
|
22
|
-
directives: {
|
|
23
|
-
defaultSrc: ["'none'"],
|
|
24
|
-
scriptSrc: ["'self'"],
|
|
25
|
-
styleSrc: ["'self'", "'unsafe-inline'", 'https://fonts.googleapis.com'],
|
|
26
|
-
fontSrc: ["'self'", 'https://fonts.gstatic.com'],
|
|
27
|
-
imgSrc: ["'self'", 'data: ', 'https://secure.gravatar.com/'],
|
|
28
|
-
connectSrc: ["'self'", 'https://www.googleapis.com'],
|
|
29
|
-
manifestSrc: ["'self'"],
|
|
30
|
-
},
|
|
31
|
-
}));
|
|
32
|
-
const { staticAssets } = options;
|
|
33
|
-
if (staticAssets) {
|
|
34
|
-
const staticOptions = staticAssets.options || {
|
|
35
|
-
index: false,
|
|
36
|
-
};
|
|
37
|
-
if (staticAssets.prefix) {
|
|
38
|
-
logging_internal_1.defaultLogger.info(`Serving static assets from ${staticAssets.root} on prefix ${staticAssets.prefix}`);
|
|
39
|
-
expressApp.use(staticAssets.prefix, express.static(staticAssets.root, staticOptions));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
logging_internal_1.defaultLogger.info(`Serving static assets from ${staticAssets.root}`);
|
|
43
|
-
expressApp.use(express.static(staticAssets.root, staticOptions));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
let secure = (options.session.cookie && options.session.cookie.secure) || false;
|
|
47
|
-
if (process.env.NODE_ENV === 'production' && process.env.APP_ENGINE_ENVIRONMENT) {
|
|
48
|
-
expressApp.set('trust proxy', true);
|
|
49
|
-
secure = true;
|
|
50
|
-
logging_internal_1.defaultLogger.info('Cookie secured for prod');
|
|
51
|
-
}
|
|
52
|
-
const sessionAge = options.sessionTimeoutInMinutes
|
|
53
|
-
? minutesToMilliseconds(options.sessionTimeoutInMinutes)
|
|
54
|
-
: MAX_AGE_DEFAULT;
|
|
55
|
-
logging_internal_1.defaultLogger.info(`Session age set to: ${sessionAge} ms`);
|
|
56
|
-
expressApp.use(session({
|
|
57
|
-
saveUninitialized: true,
|
|
58
|
-
resave: true,
|
|
59
|
-
rolling: true,
|
|
60
|
-
store: new node_datastore_session_1.DatastoreStore({
|
|
61
|
-
kind: 'express-sessions',
|
|
62
|
-
dataset: new datastore_1.Datastore({
|
|
63
|
-
apiEndpoint: options.session.apiEndpoint,
|
|
64
|
-
projectId: options.session.projectId,
|
|
65
|
-
}),
|
|
66
|
-
}),
|
|
67
|
-
secret: options.session.secret,
|
|
68
|
-
cookie: Object.assign(Object.assign({ maxAge: sessionAge }, options.session.cookie), { secure }),
|
|
69
|
-
}));
|
|
70
|
-
const { ignorePaths = [/^\/(tasks\/|system\/).*/], sameSite = true, disabled: csrfDisabled = false, } = options.csrf || {};
|
|
71
|
-
const unless = (exclusions, middleware) => {
|
|
72
|
-
return (req, res, next) => {
|
|
73
|
-
const matchesExclusion = (0, types_1.asArray)(exclusions).some(path => typeof path.test === 'function' ? path.test(req.path) : path === req.path);
|
|
74
|
-
matchesExclusion ? next() : middleware(req, res, next);
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
expressApp.use(passport.initialize());
|
|
78
|
-
expressApp.use(passport.session());
|
|
79
|
-
if (!csrfDisabled) {
|
|
80
|
-
const csrfValidator = (0, csrf_interceptor_1.CsrfValidatorWithOptions)({ sameSite });
|
|
81
|
-
expressApp.use(unless(ignorePaths, csrfValidator));
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
exports.configureExpress = configureExpress;
|
|
85
|
-
//# sourceMappingURL=configure.js.map
|
package/dist/configure.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":";;;AACA,+EAAoE;AACpE,uDAAoD;AACpD,mCAAmC;AAEnC,2CAA2C;AAC3C,kCAAkC;AAClC,qCAAqC;AACrC,8DAAmE;AACnE,wCAAkD;AAElD,mDAAmD;AACnD,iEAA2D;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C;IACrD,CAAC;AACH,CAAC,CAAC;AAnGW,QAAA,gBAAgB,oBAmG3B"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { NestMiddleware } from '@nestjs/common';
|
|
2
|
-
import { Request, Response } from 'express';
|
|
3
|
-
import { Context, IUser } from '../datastore/context';
|
|
4
|
-
import { DatastoreProvider } from '../datastore/datastore.provider';
|
|
5
|
-
import { UserService } from '../auth/user.service';
|
|
6
|
-
export interface RequestWithContext extends Request {
|
|
7
|
-
context: Context;
|
|
8
|
-
}
|
|
9
|
-
export declare class ContextMiddleware implements NestMiddleware<RequestWithContext> {
|
|
10
|
-
private readonly datastoreProvider;
|
|
11
|
-
private readonly userService;
|
|
12
|
-
private readonly logger;
|
|
13
|
-
constructor(datastoreProvider: DatastoreProvider, userService: UserService<IUser>);
|
|
14
|
-
use(req: RequestWithContext, res: Response, next: () => void): Promise<void>;
|
|
15
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextMiddleware = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const _ = require("lodash");
|
|
7
|
-
const context_1 = require("../datastore/context");
|
|
8
|
-
const logging_1 = require("../logging");
|
|
9
|
-
const datastore_provider_1 = require("../datastore/datastore.provider");
|
|
10
|
-
const user_service_1 = require("../auth/user.service");
|
|
11
|
-
let ContextMiddleware = class ContextMiddleware {
|
|
12
|
-
constructor(datastoreProvider, userService) {
|
|
13
|
-
this.datastoreProvider = datastoreProvider;
|
|
14
|
-
this.userService = userService;
|
|
15
|
-
this.logger = (0, logging_1.createLogger)('context-middleware');
|
|
16
|
-
}
|
|
17
|
-
async use(req, res, next) {
|
|
18
|
-
this.logger.info(`[${req.method}]: ${req.originalUrl}`);
|
|
19
|
-
const requestContext = (0, context_1.newContext)(this.datastoreProvider.datastore);
|
|
20
|
-
const userId = _.get(req, 'session.passport.user.id');
|
|
21
|
-
if (userId && !req.is('text/html')) {
|
|
22
|
-
requestContext.user = await this.userService.get(requestContext, userId);
|
|
23
|
-
}
|
|
24
|
-
requestContext.request = req;
|
|
25
|
-
req.context = requestContext;
|
|
26
|
-
if (next) {
|
|
27
|
-
next();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
exports.ContextMiddleware = ContextMiddleware;
|
|
32
|
-
exports.ContextMiddleware = ContextMiddleware = tslib_1.__decorate([
|
|
33
|
-
(0, common_1.Injectable)(),
|
|
34
|
-
tslib_1.__param(1, (0, common_1.Inject)(user_service_1.USER_SERVICE)),
|
|
35
|
-
tslib_1.__metadata("design:paramtypes", [datastore_provider_1.DatastoreProvider, Object])
|
|
36
|
-
], ContextMiddleware);
|
|
37
|
-
//# sourceMappingURL=context-middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-middleware.js","sourceRoot":"","sources":["../../src/context/context-middleware.ts"],"names":[],"mappings":";;;;AAAA,2CAAoE;AACpE,4BAA4B;AAE5B,kDAAkE;AAClE,wCAAkD;AAClD,wEAAoE;AACpE,uDAAiE;AAO1D,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAG5B,YACmB,iBAAoC,EACd,WAA+B;QADrD,sBAAiB,GAAjB,iBAAiB,CAAmB;QACd,gBAAW,GAAX,WAAW,CAAoB;QAEtE,IAAI,CAAC,MAAM,GAAG,IAAA,sBAAY,EAAC,oBAAoB,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAuB,EAAE,GAAa,EAAE,IAAgB;QAChE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QAExD,MAAM,cAAc,GAAG,IAAA,oBAAU,EAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAEpE,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAC;QAEtD,IAAI,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;YACnC,cAAc,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAC3E,CAAC;QAID,cAAc,CAAC,OAAO,GAAG,GAAG,CAAC;QAE7B,GAAG,CAAC,OAAO,GAAG,cAAc,CAAC;QAE7B,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,EAAE,CAAC;QACT,CAAC;IACH,CAAC;CACF,CAAA;AA/BY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAMR,mBAAA,IAAA,eAAM,EAAC,2BAAY,CAAC,CAAA;6CADe,sCAAiB;GAJ5C,iBAAiB,CA+B7B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RequestScopeInterceptor } from '../request-scope';
|
|
2
|
-
import { RequestWithContext } from './context-middleware';
|
|
3
|
-
import { Context } from '../datastore/context';
|
|
4
|
-
export declare const getContext: () => Context;
|
|
5
|
-
export declare class ContextRequestScopeInterceptor implements RequestScopeInterceptor {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
intercept(req: RequestWithContext): void;
|
|
8
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextRequestScopeInterceptor = exports.getContext = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const request_scope_1 = require("../request-scope");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const request_scope_2 = require("../request-scope/request-scope");
|
|
8
|
-
const logging_internal_1 = require("../logging/logging-internal");
|
|
9
|
-
const key = '_CONTEXT';
|
|
10
|
-
const getContext = () => (0, request_scope_2.getRequestScopeValueRequired)(key);
|
|
11
|
-
exports.getContext = getContext;
|
|
12
|
-
let ContextRequestScopeInterceptor = class ContextRequestScopeInterceptor {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.name = 'ContextRequestScopeInterceptor';
|
|
15
|
-
}
|
|
16
|
-
intercept(req) {
|
|
17
|
-
if (req.context) {
|
|
18
|
-
(0, request_scope_1.setRequestScopeValue)(key, req.context);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
logging_internal_1.defaultLogger.warn(`${this.name}: Context does not exist on Request, so cannot set it within request scope. This can cause unexpected runtime errors.`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.ContextRequestScopeInterceptor = ContextRequestScopeInterceptor;
|
|
26
|
-
exports.ContextRequestScopeInterceptor = ContextRequestScopeInterceptor = tslib_1.__decorate([
|
|
27
|
-
(0, common_1.Injectable)()
|
|
28
|
-
], ContextRequestScopeInterceptor);
|
|
29
|
-
//# sourceMappingURL=context-request-scope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-request-scope.js","sourceRoot":"","sources":["../../src/context/context-request-scope.ts"],"names":[],"mappings":";;;;AAAA,oDAAiF;AACjF,2CAA4C;AAE5C,kEAA8E;AAC9E,kEAA4D;AAG5D,MAAM,GAAG,GAAG,UAAU,CAAC;AAChB,MAAM,UAAU,GAAG,GAAY,EAAE,CAAC,IAAA,4CAA4B,EAAC,GAAG,CAAC,CAAC;AAA9D,QAAA,UAAU,cAAoD;AAGpE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAApC;QACI,SAAI,GAAW,gCAAgC,CAAC;IAW3D,CAAC;IATC,SAAS,CAAC,GAAuB;QAC/B,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,IAAA,oCAAoB,EAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,gCAAa,CAAC,IAAI,CAChB,GAAG,IAAI,CAAC,IAAI,uHAAuH,CACpI,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAZY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;GACA,8BAA8B,CAY1C"}
|
package/dist/context/index.d.ts
DELETED
package/dist/context/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextMiddleware = exports.getContext = exports.ContextRequestScopeInterceptor = void 0;
|
|
4
|
-
var context_request_scope_1 = require("./context-request-scope");
|
|
5
|
-
Object.defineProperty(exports, "ContextRequestScopeInterceptor", { enumerable: true, get: function () { return context_request_scope_1.ContextRequestScopeInterceptor; } });
|
|
6
|
-
Object.defineProperty(exports, "getContext", { enumerable: true, get: function () { return context_request_scope_1.getContext; } });
|
|
7
|
-
var context_middleware_1 = require("./context-middleware");
|
|
8
|
-
Object.defineProperty(exports, "ContextMiddleware", { enumerable: true, get: function () { return context_middleware_1.ContextMiddleware; } });
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":";;;AAAA,iEAAqF;AAA5E,uIAAA,8BAA8B,OAAA;AAAE,mHAAA,UAAU,OAAA;AACnD,2DAA6E;AAAhD,uHAAA,iBAAiB,OAAA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { DatastoreLoader } from './loader';
|
|
2
|
-
import { Datastore } from '@google-cloud/datastore';
|
|
3
|
-
import { Request } from 'express';
|
|
4
|
-
declare const ContextType: unique symbol;
|
|
5
|
-
export interface IUserUpdates {
|
|
6
|
-
email?: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
enabled?: boolean;
|
|
9
|
-
roles?: ReadonlyArray<string>;
|
|
10
|
-
orgId?: string;
|
|
11
|
-
props?: any;
|
|
12
|
-
}
|
|
13
|
-
export interface IUserCreateRequest extends IUserUpdates {
|
|
14
|
-
email: string;
|
|
15
|
-
}
|
|
16
|
-
export interface IUser extends IUserCreateRequest {
|
|
17
|
-
id: string;
|
|
18
|
-
enabled: boolean;
|
|
19
|
-
roles: ReadonlyArray<string>;
|
|
20
|
-
orgId?: string;
|
|
21
|
-
}
|
|
22
|
-
export declare const Ctxt: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
23
|
-
export interface Context<User = IUser> {
|
|
24
|
-
request: Request;
|
|
25
|
-
datastore: DatastoreLoader;
|
|
26
|
-
user?: User;
|
|
27
|
-
hasAnyRole(...roles: string[]): boolean;
|
|
28
|
-
props: {
|
|
29
|
-
[key: string]: any;
|
|
30
|
-
};
|
|
31
|
-
[ContextType]: true;
|
|
32
|
-
}
|
|
33
|
-
export declare function isContext(value: object): value is Context;
|
|
34
|
-
export declare const newContext: (datastore: Datastore) => Context;
|
|
35
|
-
export declare const transaction: <T>(context: Context, callback: (context: Context) => Promise<T>) => Promise<T>;
|
|
36
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transaction = exports.newContext = exports.Ctxt = void 0;
|
|
4
|
-
exports.isContext = isContext;
|
|
5
|
-
const loader_1 = require("./loader");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const _ = require("lodash");
|
|
8
|
-
const ContextType = Symbol();
|
|
9
|
-
exports.Ctxt = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
10
|
-
const request = ctx.switchToHttp().getRequest();
|
|
11
|
-
return request.context;
|
|
12
|
-
});
|
|
13
|
-
function isContext(value) {
|
|
14
|
-
return !!value[ContextType];
|
|
15
|
-
}
|
|
16
|
-
const newContext = (datastore) => {
|
|
17
|
-
const context = { [ContextType]: true, props: [] };
|
|
18
|
-
context.datastore = new loader_1.DatastoreLoader(datastore, context);
|
|
19
|
-
context.hasAnyRole = (...roles) => !!context.user && context.user.roles.some(r => _.includes(roles, r));
|
|
20
|
-
return context;
|
|
21
|
-
};
|
|
22
|
-
exports.newContext = newContext;
|
|
23
|
-
const transaction = async (context, callback) => {
|
|
24
|
-
return await callback(context);
|
|
25
|
-
};
|
|
26
|
-
exports.transaction = transaction;
|
|
27
|
-
//# sourceMappingURL=context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/datastore/context.ts"],"names":[],"mappings":";;;AA4CA,8BAEC;AA9CD,qCAA2C;AAE3C,2CAAwE;AACxE,4BAA6B;AAG7B,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC;AAsBhB,QAAA,IAAI,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IAChF,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC,CAAC,CAAC;AAaH,SAAgB,SAAS,CAAC,KAAa;IACrC,OAAO,CAAC,CAAE,KAAa,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAEM,MAAM,UAAU,GAAG,CAAC,SAAoB,EAAW,EAAE;IAC1D,MAAM,OAAO,GAAQ,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACxD,OAAO,CAAC,SAAS,GAAG,IAAI,wBAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5D,OAAO,CAAC,UAAU,GAAG,CAAC,GAAG,KAAe,EAAE,EAAE,CAC1C,CAAC,CAAC,OAAO,CAAC,IAAI,IAAK,OAAO,CAAC,IAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAClF,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB;AAEK,MAAM,WAAW,GAAG,KAAK,EAAK,OAAgB,EAAE,QAA0C,EAAc,EAAE;IAC/G,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Datastore } from '@google-cloud/datastore';
|
|
2
|
-
import { Configuration } from '../';
|
|
3
|
-
export declare class DatastoreProvider {
|
|
4
|
-
private readonly datastoreConnection;
|
|
5
|
-
private readonly logger;
|
|
6
|
-
constructor(configuration: Configuration);
|
|
7
|
-
get datastore(): Datastore;
|
|
8
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatastoreProvider = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const datastore_1 = require("@google-cloud/datastore");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const __1 = require("../");
|
|
8
|
-
let DatastoreProvider = class DatastoreProvider {
|
|
9
|
-
constructor(configuration) {
|
|
10
|
-
this.logger = (0, __1.createLogger)('datastore-provider');
|
|
11
|
-
const { projectId, apiEndpoint } = configuration;
|
|
12
|
-
if (apiEndpoint) {
|
|
13
|
-
this.logger.info('API endpoint provided for datastore, connecting to local emulator.');
|
|
14
|
-
}
|
|
15
|
-
this.datastoreConnection = new datastore_1.Datastore({
|
|
16
|
-
projectId,
|
|
17
|
-
apiEndpoint,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
get datastore() {
|
|
21
|
-
return this.datastoreConnection;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.DatastoreProvider = DatastoreProvider;
|
|
25
|
-
exports.DatastoreProvider = DatastoreProvider = tslib_1.__decorate([
|
|
26
|
-
(0, common_1.Injectable)(),
|
|
27
|
-
tslib_1.__param(0, (0, common_1.Inject)('Configuration')),
|
|
28
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
29
|
-
], DatastoreProvider);
|
|
30
|
-
//# sourceMappingURL=datastore.provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datastore.provider.js","sourceRoot":"","sources":["../../src/datastore/datastore.provider.ts"],"names":[],"mappings":";;;;AAAA,uDAAoD;AACpD,2CAAoD;AACpD,2BAA0D;AAGnD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAI5B,YAAqC,aAA4B;QAFhD,WAAM,GAAW,IAAA,gBAAY,EAAC,oBAAoB,CAAC,CAAC;QAGnE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,aAAa,CAAC;QAEjD,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;QACzF,CAAC;QAED,IAAI,CAAC,mBAAmB,GAAG,IAAI,qBAAS,CAAC;YACvC,SAAS;YACT,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;CACF,CAAA;AApBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAKE,mBAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;;GAJzB,iBAAiB,CAoB7B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { OneOrMany } from '../util/types';
|
|
2
|
-
import { Operator } from '@google-cloud/datastore/build/src/query';
|
|
3
|
-
export type Filter<T> = OneOrMany<T | ComplexFilter<T>>;
|
|
4
|
-
export interface ComplexFilter<T> {
|
|
5
|
-
op: Operator;
|
|
6
|
-
value: T;
|
|
7
|
-
}
|
|
8
|
-
type FilterType<T> = [T] extends [Date] ? Filter<T> : [T] extends [object] ? Filters<T> : Filter<T>;
|
|
9
|
-
type FilterArray<T extends any[]> = T[0] extends object ? Filters<T[0]> : FilterType<T[0]>;
|
|
10
|
-
export type Filters<T> = {
|
|
11
|
-
[K in keyof T]?: T[K] extends any[] ? FilterArray<T[K]> : FilterType<T[K]>;
|
|
12
|
-
};
|
|
13
|
-
export declare function isComplexFilter<T>(filter: Filter<T>): filter is ComplexFilter<T>;
|
|
14
|
-
interface Query {
|
|
15
|
-
filter(path: string, operation: Operator, value: any): this;
|
|
16
|
-
filter(path: string, value: any): this;
|
|
17
|
-
}
|
|
18
|
-
export declare const buildFilters: <T, Q extends Query>(query: Q, filters: Filters<T>, pathPrefix?: string) => Q;
|
|
19
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildFilters = void 0;
|
|
4
|
-
exports.isComplexFilter = isComplexFilter;
|
|
5
|
-
const types_1 = require("../util/types");
|
|
6
|
-
function isComplexFilter(filter) {
|
|
7
|
-
return filter.op !== undefined;
|
|
8
|
-
}
|
|
9
|
-
const buildFilters = (query, filters, pathPrefix = '') => {
|
|
10
|
-
return Object.entries(filters).reduce((q, [key, value]) => {
|
|
11
|
-
if (!isComplexFilter(value) && typeof value === 'object' && !Array.isArray(value)) {
|
|
12
|
-
return (0, exports.buildFilters)(query, value, pathPrefix + `${key}.`);
|
|
13
|
-
}
|
|
14
|
-
const parameterFilters = (0, types_1.asArray)(value);
|
|
15
|
-
for (const filter of parameterFilters) {
|
|
16
|
-
if (isComplexFilter(filter)) {
|
|
17
|
-
q = q.filter(pathPrefix + key, filter.op, filter.value);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
q = q.filter(pathPrefix + key, filter);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return q;
|
|
24
|
-
}, query);
|
|
25
|
-
};
|
|
26
|
-
exports.buildFilters = buildFilters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AY,gBAkBvB"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Datastore, Transaction } from '@google-cloud/datastore';
|
|
2
|
-
import { entity as Entity } from '@google-cloud/datastore/build/src/entity';
|
|
3
|
-
import { OrderOptions, RunQueryInfo } from '@google-cloud/datastore/build/src/query';
|
|
4
|
-
import { OneOrMany } from '../util/types';
|
|
5
|
-
import { Context } from './context';
|
|
6
|
-
import { Filters } from './filters';
|
|
7
|
-
export type Index<T> = true | {
|
|
8
|
-
[K in keyof T]?: T[K] extends Array<any> ? Index<T[K][0]> : Index<T[K]>;
|
|
9
|
-
};
|
|
10
|
-
export interface PropertySort<T> {
|
|
11
|
-
property: (keyof T | '__key__') & string;
|
|
12
|
-
options?: OrderOptions;
|
|
13
|
-
}
|
|
14
|
-
export interface QueryOptions<T> {
|
|
15
|
-
select: OneOrMany<keyof T & string>;
|
|
16
|
-
filters: Filters<T>;
|
|
17
|
-
sort: OneOrMany<PropertySort<T>>;
|
|
18
|
-
groupBy: OneOrMany<keyof T & string>;
|
|
19
|
-
start: string;
|
|
20
|
-
end: string;
|
|
21
|
-
hasAnscestor: Entity.Key;
|
|
22
|
-
offset: number;
|
|
23
|
-
limit: number;
|
|
24
|
-
}
|
|
25
|
-
export interface DatastorePayload<T> {
|
|
26
|
-
key: Entity.Key;
|
|
27
|
-
data: T | object;
|
|
28
|
-
excludeFromIndexes?: string[];
|
|
29
|
-
}
|
|
30
|
-
export type WithDatstoreKey<T> = T & {
|
|
31
|
-
[Entity.KEY_SYMBOL]: Entity.Key;
|
|
32
|
-
};
|
|
33
|
-
export declare class DatastoreLoader {
|
|
34
|
-
private readonly loader;
|
|
35
|
-
private readonly datastore;
|
|
36
|
-
private readonly parentContext;
|
|
37
|
-
private readonly logger;
|
|
38
|
-
constructor(datastore: Datastore | Transaction, context: Context);
|
|
39
|
-
get(ids: Entity.Key[]): Promise<object[]>;
|
|
40
|
-
save(entities: ReadonlyArray<DatastorePayload<any>>): Promise<void>;
|
|
41
|
-
delete(entities: ReadonlyArray<Entity.Key>): Promise<void>;
|
|
42
|
-
update(entities: ReadonlyArray<DatastorePayload<any>>): Promise<void>;
|
|
43
|
-
upsert(entities: ReadonlyArray<DatastorePayload<any>>): Promise<void>;
|
|
44
|
-
insert(entities: ReadonlyArray<DatastorePayload<any>>): Promise<void>;
|
|
45
|
-
executeQuery<T>(kind: string, options: Partial<QueryOptions<T>>): Promise<[WithDatstoreKey<T>[], RunQueryInfo]>;
|
|
46
|
-
inTransaction<T>(callback: (tx: Context) => Promise<T>): Promise<T>;
|
|
47
|
-
private resetDataloaderCache;
|
|
48
|
-
private applyBatched;
|
|
49
|
-
private load;
|
|
50
|
-
}
|