@emuanalytics/flow-engine-client 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +2 -2
- package/dist/bundle.js.map +4 -4
- package/dist/cjs/lib/api-interfaces.js.map +1 -1
- package/dist/cjs/lib/client.js +10 -0
- package/dist/cjs/lib/client.js.map +1 -1
- package/dist/cjs/lib/contact-point.endpoints.js +46 -0
- package/dist/cjs/lib/contact-point.endpoints.js.map +1 -0
- package/dist/cjs/lib/media.endpoints.js +106 -0
- package/dist/cjs/lib/media.endpoints.js.map +1 -0
- package/dist/esm/lib/api-interfaces.js.map +1 -1
- package/dist/esm/lib/client.js +10 -0
- package/dist/esm/lib/client.js.map +1 -1
- package/dist/esm/lib/contact-point.endpoints.js +43 -0
- package/dist/esm/lib/contact-point.endpoints.js.map +1 -0
- package/dist/esm/lib/media.endpoints.js +100 -0
- package/dist/esm/lib/media.endpoints.js.map +1 -0
- package/dist/types/lib/api-interfaces.d.ts +48 -0
- package/dist/types/lib/api-interfaces.d.ts.map +1 -1
- package/dist/types/lib/client.d.ts +6 -0
- package/dist/types/lib/client.d.ts.map +1 -1
- package/dist/types/lib/contact-point.endpoints.d.ts +20 -0
- package/dist/types/lib/contact-point.endpoints.d.ts.map +1 -0
- package/dist/types/lib/media.endpoints.d.ts +20 -0
- package/dist/types/lib/media.endpoints.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-interfaces.js","sourceRoot":"","sources":["../../../src/lib/api-interfaces.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nexport interface IQuery {\n filter?: { [key: string]: any };\n attributes?: string | string[];\n join?: string | string[];\n limit?: number;\n offset?: number;\n sort?: string | string[];\n}\n\nexport interface IBaseResource {\n id: string;\n}\n\nexport interface IMetadata {\n [key: string]: any;\n}\n\nexport interface IPermissions {\n [key: string]: { [key: string]: string };\n}\n\nexport interface IApiKey extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n description: string;\n type: 'app' | 'master';\n permissions: IPermissions;\n metadata: IMetadata;\n userId: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IApplication extends IBaseResource {\n id: string;\n name: string;\n databases?: IDatabase[];\n description: string;\n contact: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IAppConfig extends IBaseResource {\n applicationId: string;\n config: object;\n}\n\nexport interface IDatabase extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: string;\n name: string;\n default: boolean;\n description: string;\n host: string;\n port: number;\n user: string;\n password: string;\n db: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IDatasetAttribute {\n attribute: string;\n type: string;\n dbType: string;\n isGeometry?: boolean;\n srid?: number;\n extent?: number[];\n extentLngLat?: number[];\n primaryKey?: boolean;\n default?: string;\n nullable?: boolean;\n description?: string;\n}\n\nexport interface IDataset extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: 'table' | 'sql';\n source: string;\n name: string;\n databaseId: string;\n database?: IDatabase;\n description: string;\n bytes: number;\n metadata: IMetadata;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n attributes: IDatasetAttribute[];\n options?: { [key: string]: any };\n}\nexport interface IMapLayer extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n\n id: string;\n name: string;\n description: string;\n layerSpec: any;\n type: string;\n group: string;\n metadata: IMetadata;\n}\n\nexport type FileExportFormat = 'geojson' | 'gpkg' | 'shapefile';\n\nexport interface ITileSource extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n metadata: IMetadata;\n id: string;\n type: string;\n source: string;\n attribution: string;\n minZoom: number;\n maxZoom: number;\n headers: { [key: string]: string };\n extentLngLat: number[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IUpload extends IBaseResource {\n id: string;\n fileName: string;\n path: string;\n options: {\n name: string;\n description?: string;\n datasetId: string;\n attribution?: string;\n schema?: string;\n };\n size: number;\n status: string;\n error: { message: string; stdout: string; stderr: string };\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n updatedAt: string;\n createdAt: string;\n}\n\nexport interface IUser extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface IStyle extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface ITileSpec {\n [key: string]: any;\n}\n\nexport interface IConfig {\n version: {\n tag: string;\n hash: string;\n timestamp: number;\n };\n}\n\nexport interface ILoginResponse {\n accessToken: string;\n refreshToken: string;\n}\n\nexport interface ITokenRefreshResponse {\n accessToken: string;\n}\n\nexport interface UsersMeResponse {\n applicationId: string;\n email: string;\n firstName: string;\n id: string;\n lastName: string;\n metadata: object;\n roles: string[];\n}\n\n/* Job resource */\nexport type JobStatus = 'pending' | 'processing' | 'done' | 'cancelled' | 'error';\n\nexport interface IJob {\n id: string;\n applicationId: string;\n ownerId?: string;\n metadata: IMetadata;\n type: string;\n name?: string;\n description?: string;\n params: any;\n status: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n datasetId?: string;\n createdAt: string;\n updatedAt: string;\n}\nexport interface IJobStatus {\n status?: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n}\n\nexport interface IJobSubmission {\n type: string;\n name?: string;\n description?: string;\n params: any;\n}\n\nexport interface IJobRequest {\n type: string;\n}\n\nexport type IngestAction = 'insert' | 'upsert' | 'delete';\nexport interface IIngestMessage {\n datasetId: string;\n action: IngestAction;\n data: any;\n}\n\nexport interface IPipeline extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n environment: string;\n description: string;\n config: Record<string, any>;\n metadata: IMetadata;\n startedAt: string;\n heartbeatAt: string;\n createdAt: string;\n updatedAt: string;\n components?: IPipelineComponent[];\n}\n\nexport interface IPipelineComponent extends IBaseResource {\n id: string;\n description: string;\n config: Record<string, any>;\n class: string;\n type: string;\n metadata: IMetadata;\n index: number;\n createdAt: string;\n updatedAt: string;\n metrics?: IPipelineMetric[];\n}\n\nexport interface IPipelineMetric extends IBaseResource {\n id: string;\n applicationId: string;\n pipelineId: string;\n componentId: string;\n name: string;\n type: string;\n timestamp: string;\n value: number;\n labels: Record<string, string>;\n createdAt: string;\n updatedAt: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api-interfaces.js","sourceRoot":"","sources":["../../../src/lib/api-interfaces.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nexport interface IQuery {\n filter?: { [key: string]: any };\n attributes?: string | string[];\n join?: string | string[];\n limit?: number;\n offset?: number;\n sort?: string | string[];\n}\n\nexport interface IBaseResource {\n id: string;\n}\n\nexport interface IMetadata {\n [key: string]: any;\n}\n\nexport interface IPermissions {\n [key: string]: { [key: string]: string };\n}\n\nexport interface IApiKey extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n description: string;\n type: 'app' | 'master';\n permissions: IPermissions;\n metadata: IMetadata;\n userId: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IApplication extends IBaseResource {\n id: string;\n name: string;\n databases?: IDatabase[];\n description: string;\n contact: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IAppConfig extends IBaseResource {\n applicationId: string;\n config: object;\n}\n\nexport interface IDatabase extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: string;\n name: string;\n default: boolean;\n description: string;\n host: string;\n port: number;\n user: string;\n password: string;\n db: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IDatasetAttribute {\n attribute: string;\n type: string;\n dbType: string;\n isGeometry?: boolean;\n srid?: number;\n extent?: number[];\n extentLngLat?: number[];\n primaryKey?: boolean;\n default?: string;\n nullable?: boolean;\n description?: string;\n}\n\nexport interface IDataset extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: 'table' | 'sql';\n source: string;\n name: string;\n databaseId: string;\n database?: IDatabase;\n description: string;\n bytes: number;\n metadata: IMetadata;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n attributes: IDatasetAttribute[];\n options?: { [key: string]: any };\n}\nexport interface IMapLayer extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n\n id: string;\n name: string;\n description: string;\n layerSpec: any;\n type: string;\n group: string;\n metadata: IMetadata;\n}\n\nexport type FileExportFormat = 'geojson' | 'gpkg' | 'shapefile';\n\nexport interface ITileSource extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n metadata: IMetadata;\n id: string;\n type: string;\n source: string;\n attribution: string;\n minZoom: number;\n maxZoom: number;\n headers: { [key: string]: string };\n extentLngLat: number[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IUpload extends IBaseResource {\n id: string;\n fileName: string;\n path: string;\n options: {\n name: string;\n description?: string;\n datasetId: string;\n attribution?: string;\n schema?: string;\n };\n size: number;\n status: string;\n error: { message: string; stdout: string; stderr: string };\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n updatedAt: string;\n createdAt: string;\n}\n\nexport interface IUser extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface IStyle extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface ITileSpec {\n [key: string]: any;\n}\n\nexport interface IConfig {\n version: {\n tag: string;\n hash: string;\n timestamp: number;\n };\n}\n\nexport interface ILoginResponse {\n accessToken: string;\n refreshToken: string;\n}\n\nexport interface ITokenRefreshResponse {\n accessToken: string;\n}\n\nexport interface UsersMeResponse {\n applicationId: string;\n email: string;\n firstName: string;\n id: string;\n lastName: string;\n metadata: object;\n roles: string[];\n}\n\n/* Job resource */\nexport type JobStatus = 'pending' | 'processing' | 'done' | 'cancelled' | 'error';\n\nexport interface IJob {\n id: string;\n applicationId: string;\n ownerId?: string;\n metadata: IMetadata;\n type: string;\n name?: string;\n description?: string;\n params: any;\n status: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n datasetId?: string;\n createdAt: string;\n updatedAt: string;\n}\nexport interface IJobStatus {\n status?: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n}\n\nexport interface IJobSubmission {\n type: string;\n name?: string;\n description?: string;\n params: any;\n}\n\nexport interface IJobRequest {\n type: string;\n}\n\nexport type IngestAction = 'insert' | 'upsert' | 'delete';\nexport interface IIngestMessage {\n datasetId: string;\n action: IngestAction;\n data: any;\n}\n\nexport interface IPipeline extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n environment: string;\n description: string;\n config: Record<string, any>;\n metadata: IMetadata;\n startedAt: string;\n heartbeatAt: string;\n createdAt: string;\n updatedAt: string;\n components?: IPipelineComponent[];\n}\n\nexport interface IPipelineComponent extends IBaseResource {\n id: string;\n description: string;\n config: Record<string, any>;\n class: string;\n type: string;\n metadata: IMetadata;\n index: number;\n createdAt: string;\n updatedAt: string;\n metrics?: IPipelineMetric[];\n}\n\nexport interface IPipelineMetric extends IBaseResource {\n id: string;\n applicationId: string;\n pipelineId: string;\n componentId: string;\n name: string;\n type: string;\n timestamp: string;\n value: number;\n labels: Record<string, string>;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Contact point resource.\n */\nexport interface IContactPoint extends IBaseResource {\n id: string;\n applicationId: string;\n type: string;\n description: string;\n templates: string[];\n recipients: string[];\n /** Driver-specific host configuration for the contact point */\n host: string;\n /** Driver-specific port configuration for the contact point */\n port: number;\n /** Driver-specific user configuration for the contact point */\n user: string;\n /** Driver-specific password configuration for the contact point */\n password: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Request body for sending a notification to a contact point.\n */\nexport interface IContactPointSendRequest {\n /** ID of the template to use for the notification */\n template?: string;\n /** Subject of the notification */\n subject?: string;\n /** Recipients of the notification */\n recipients?: string[];\n /** Template key/value data for expanding the notification template */\n data?: any;\n}\n\n/**\n * Media resource.\n */\nexport interface IMedia extends IBaseResource {\n id: string;\n applicationId: string;\n type: string;\n mimeType: string;\n fileName: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n"]}
|
package/dist/cjs/lib/client.js
CHANGED
|
@@ -24,12 +24,14 @@ var apikey_endpoints_1 = require("./apikey.endpoints");
|
|
|
24
24
|
var appconfig_endpoints_1 = require("./appconfig.endpoints");
|
|
25
25
|
var application_endpoints_1 = require("./application.endpoints");
|
|
26
26
|
var auth_edpoints_1 = require("./auth.edpoints");
|
|
27
|
+
var contact_point_endpoints_1 = require("./contact-point.endpoints");
|
|
27
28
|
var database_endpoints_1 = require("./database.endpoints");
|
|
28
29
|
var dataset_endpoints_1 = require("./dataset.endpoints");
|
|
29
30
|
var errors_1 = require("./errors");
|
|
30
31
|
var job_endpoints_1 = require("./job.endpoints");
|
|
31
32
|
var map_endoints_1 = require("./map.endoints");
|
|
32
33
|
var maplayer_endpoints_1 = require("./maplayer.endpoints");
|
|
34
|
+
var media_endpoints_1 = require("./media.endpoints");
|
|
33
35
|
var pipeline_endpoints_1 = require("./pipeline.endpoints");
|
|
34
36
|
var style_endpoint_1 = require("./style.endpoint");
|
|
35
37
|
var tile_source_endpoints_1 = require("./tile-source.endpoints");
|
|
@@ -49,6 +51,7 @@ var Client = /** @class */ (function () {
|
|
|
49
51
|
this.apiKeys = new apikey_endpoints_1.ApiKeyEndpoints(this);
|
|
50
52
|
this.applications = new application_endpoints_1.ApplicationEndpoints(this);
|
|
51
53
|
this.appconfig = new appconfig_endpoints_1.AppConfigEndpoints(this);
|
|
54
|
+
this.contactpoints = new contact_point_endpoints_1.ContactPointEndpoints(this);
|
|
52
55
|
this.databases = new database_endpoints_1.DatabaseEndpoints(this);
|
|
53
56
|
this.datasets = new dataset_endpoints_1.DatasetEndpoints(this);
|
|
54
57
|
this.styles = new style_endpoint_1.StyleEndpoints(this);
|
|
@@ -56,6 +59,7 @@ var Client = /** @class */ (function () {
|
|
|
56
59
|
this.uploads = new upload_endpoints_1.UploadEndpoints(this);
|
|
57
60
|
this.jobs = new job_endpoints_1.JobEndpoints(this);
|
|
58
61
|
this.maplayers = new maplayer_endpoints_1.MapLayerEndpoints(this);
|
|
62
|
+
this.media = new media_endpoints_1.MediaEndpoints(this);
|
|
59
63
|
this.pipelines = new pipeline_endpoints_1.PipelineEndpoints(this);
|
|
60
64
|
this.axios = axios_1.default.create({
|
|
61
65
|
baseURL: baseUrl,
|
|
@@ -75,6 +79,12 @@ var Client = /** @class */ (function () {
|
|
|
75
79
|
});
|
|
76
80
|
this.webSocketGateway = new web_socket_gateway_1.WebSocketGateway(this, options);
|
|
77
81
|
}
|
|
82
|
+
Client.prototype.useRequestInterceptor = function (interceptor) {
|
|
83
|
+
return this.axios.interceptors.request.use(interceptor);
|
|
84
|
+
};
|
|
85
|
+
Client.prototype.ejectRequestInterceptor = function (id) {
|
|
86
|
+
this.axios.interceptors.request.eject(id);
|
|
87
|
+
};
|
|
78
88
|
Client.prototype.connect = function () {
|
|
79
89
|
return this.webSocketGateway.connect();
|
|
80
90
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,gDAAyD;AACzD,gDAA0B;AAE1B,uDAAqD;AACrD,6DAA2D;AAC3D,iEAA+D;AAC/D,iDAAgD;AAChD,2DAAyD;AACzD,yDAAuD;AACvD,mCAA2C;AAC3C,iDAA+C;AAC/C,+CAA8C;AAC9C,2DAAyD;AACzD,2DAAyD;AACzD,mDAAkD;AAClD,iEAA8D;AAC9D,mDAAiD;AACjD,uDAAqD;AACrD,2DAM8B;AAI9B;IAuBE,gBAAmB,OAAe,EAAkB,MAA4B,EAAE,OAAuB;QAArD,uBAAA,EAAA,aAA4B;QAA7D,YAAO,GAAP,OAAO,CAAQ;QAAkB,WAAM,GAAN,MAAM,CAAsB;QArBvE,UAAK,GAAG,IAAA,eAAK,EAAC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C,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACvF,CAAC;iBAAM,IAAI,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC/C,MAAM,IAAI,wBAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,gBAAgB;QAEhB,kCAAkC;QAClC,IAAM,UAAU,GAAQ,CAAC,CAAC;QAC1B,OAAO,UAAU,CAAC,MAAM,CAAC;QACzB,OAAO,UAAU,CAAC,OAAO,CAAC;QAC1B,OAAO,UAAU,CAAC,QAAQ,CAAC;QAE3B,MAAM,IAAI,wBAAe,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IAEO,wBAAO,GAAf,UAAgB,OAAY;QAC1B,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QAEtC,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QACvD,CAAC;QAED,2EAA2E;QAC3E,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,iBAAU,IAAI,CAAC,WAAW,CAAE,CAAC;QAChF,CAAC;QAED,OAAO,EAAE,OAAO,SAAA,EAAE,CAAC;IACrB,CAAC;IACH,aAAC;AAAD,CAAC,AA3LD,IA2LC;AA3LY,wBAAM","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nimport Axios, { AxiosError, AxiosInstance } from 'axios';\nimport Debug from 'debug';\nimport { IConfig } from './api-interfaces';\nimport { ApiKeyEndpoints } from './apikey.endpoints';\nimport { AppConfigEndpoints } from './appconfig.endpoints';\nimport { ApplicationEndpoints } from './application.endpoints';\nimport { AuthEndpoints } from './auth.edpoints';\nimport { DatabaseEndpoints } from './database.endpoints';\nimport { DatasetEndpoints } from './dataset.endpoints';\nimport { FlowEngineError } from './errors';\nimport { JobEndpoints } from './job.endpoints';\nimport { MapEndpoints } from './map.endoints';\nimport { MapLayerEndpoints } from './maplayer.endpoints';\nimport { PipelineEndpoints } from './pipeline.endpoints';\nimport { StyleEndpoints } from './style.endpoint';\nimport { TileSourceEndpoints } from './tile-source.endpoints';\nimport { TileEndpoints } from './tile.endpoints';\nimport { UploadEndpoints } from './upload.endpoints';\nimport {\n WebSocketGateway,\n WebSocketManagerOptions,\n WebSocketSubscribeCallback,\n WebSocketUnsubscribeCallback,\n WebSocketUnsubscriber\n} from './web-socket-gateway';\n\nexport type ClientOptions = WebSocketManagerOptions;\n\nexport class Client {\n private readonly axios: AxiosInstance;\n readonly debug = Debug('flow-engine-client');\n\n public webSocketGateway: WebSocketGateway;\n\n accessToken: string | null = null;\n\n auth = new AuthEndpoints(this);\n tiles = new TileEndpoints(this);\n maps = new MapEndpoints(this);\n apiKeys = new ApiKeyEndpoints(this);\n applications = new ApplicationEndpoints(this);\n appconfig = new AppConfigEndpoints(this);\n databases = new DatabaseEndpoints(this);\n datasets = new DatasetEndpoints(this);\n styles = new StyleEndpoints(this);\n tileSources = new TileSourceEndpoints(this);\n uploads = new UploadEndpoints(this);\n jobs = new JobEndpoints(this);\n maplayers = new MapLayerEndpoints(this);\n pipelines = new PipelineEndpoints(this);\n\n constructor(public baseUrl: string, public readonly apiKey: string | null = null, options?: ClientOptions) {\n this.axios = Axios.create({\n baseURL: baseUrl,\n maxContentLength: 524288000,\n transformResponse: [\n function transformResponse(data, headers) {\n if (headers?.['content-type']?.startsWith('application/json')) {\n // Force parsing of data if expected content type is JSON\n // This ensures that errors are thrown if JSON is truncated due to a query timeout\n // (default Axios behavior is simply to return a string if JSON parsing fails)\n return JSON.parse(data);\n }\n\n return data;\n }\n ]\n });\n\n this.webSocketGateway = new WebSocketGateway(this, options);\n }\n\n connect(): Promise<void> {\n return this.webSocketGateway.connect();\n }\n\n disconnect(): Promise<void> {\n return this.webSocketGateway.disconnect();\n }\n\n config(): Promise<IConfig> {\n return this._get('/api/v1/config');\n }\n\n _get(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'get',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _post(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'post',\n url: path,\n data,\n maxContentLength: Infinity,\n maxBodyLength: Infinity,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _put(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'put',\n url: path,\n data,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _delete(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'delete',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n // Subscribe to named channel - errors and messages are delivered via the callback\n _subscribe(channel: string, cb: WebSocketSubscribeCallback): WebSocketUnsubscriber {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n\n return this.webSocketGateway.subscribe(channel, cb);\n }\n\n // Unsubscribe from named channel - optional callback is called on completion\n _unsubscribe(channel: string, cb?: WebSocketUnsubscribeCallback) {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n this.webSocketGateway.unsubscribe(channel, cb);\n }\n\n /**\n * Normalize errors\n * Throws a new error based on type of input error\n *\n * @param {AxiosError} e\n */\n private handleError(e: AxiosError) {\n // Flow API error\n if (e.response && e.response.data) {\n if (typeof e.response.data === 'object') {\n const data: any = e.response.data;\n throw new FlowEngineError(data.message || data.error, data.error, e.response.status);\n } else if (typeof e.response.data === 'string') {\n throw new FlowEngineError(e.response.data, null, e.response.status);\n }\n }\n\n // Generic error\n\n // Don't leak information in error\n const cleanError: any = e;\n delete cleanError.config;\n delete cleanError.request;\n delete cleanError.response;\n\n throw new FlowEngineError(cleanError.message, cleanError);\n }\n\n private headers(options: any) {\n const headers = options.headers || {};\n\n if (options.apiKey || this.apiKey) {\n headers['X-Api-Key'] = options.apiKey || this.apiKey;\n }\n\n // Add default auth header if token supplied and not already set in options\n if (this.accessToken) {\n headers.Authorization = headers.Authorization || `Bearer ${this.accessToken}`;\n }\n\n return { headers };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,gDAAyD;AACzD,gDAA0B;AAE1B,uDAAqD;AACrD,6DAA2D;AAC3D,iEAA+D;AAC/D,iDAAgD;AAChD,qEAAkE;AAClE,2DAAyD;AACzD,yDAAuD;AACvD,mCAA2C;AAC3C,iDAA+C;AAC/C,+CAA8C;AAC9C,2DAAyD;AACzD,qDAAmD;AACnD,2DAAyD;AACzD,mDAAkD;AAClD,iEAA8D;AAC9D,mDAAiD;AACjD,uDAAqD;AACrD,2DAM8B;AAI9B;IAiCE,gBAAmB,OAAe,EAAkB,MAA4B,EAAE,OAAuB;QAArD,uBAAA,EAAA,aAA4B;QAA7D,YAAO,GAAP,OAAO,CAAQ;QAAkB,WAAM,GAAN,MAAM,CAAsB;QA/BvE,UAAK,GAAG,IAAA,eAAK,EAAC,o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E,CAAC;YACrB,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,iBAAU,IAAI,CAAC,WAAW,CAAE,CAAC;QAChF,CAAC;QAED,OAAO,EAAE,OAAO,SAAA,EAAE,CAAC;IACrB,CAAC;IACH,aAAC;AAAD,CAAC,AArMD,IAqMC;AArMY,wBAAM","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nimport Axios, { AxiosError, AxiosInstance } from 'axios';\nimport Debug from 'debug';\nimport { IConfig } from './api-interfaces';\nimport { ApiKeyEndpoints } from './apikey.endpoints';\nimport { AppConfigEndpoints } from './appconfig.endpoints';\nimport { ApplicationEndpoints } from './application.endpoints';\nimport { AuthEndpoints } from './auth.edpoints';\nimport { ContactPointEndpoints } from './contact-point.endpoints';\nimport { DatabaseEndpoints } from './database.endpoints';\nimport { DatasetEndpoints } from './dataset.endpoints';\nimport { FlowEngineError } from './errors';\nimport { JobEndpoints } from './job.endpoints';\nimport { MapEndpoints } from './map.endoints';\nimport { MapLayerEndpoints } from './maplayer.endpoints';\nimport { MediaEndpoints } from './media.endpoints';\nimport { PipelineEndpoints } from './pipeline.endpoints';\nimport { StyleEndpoints } from './style.endpoint';\nimport { TileSourceEndpoints } from './tile-source.endpoints';\nimport { TileEndpoints } from './tile.endpoints';\nimport { UploadEndpoints } from './upload.endpoints';\nimport {\n WebSocketGateway,\n WebSocketManagerOptions,\n WebSocketSubscribeCallback,\n WebSocketUnsubscribeCallback,\n WebSocketUnsubscriber\n} from './web-socket-gateway';\n\nexport type ClientOptions = WebSocketManagerOptions;\n\nexport class Client {\n private readonly axios: AxiosInstance;\n readonly debug = Debug('flow-engine-client');\n\n public webSocketGateway: WebSocketGateway;\n\n accessToken: string | null = null;\n\n auth = new AuthEndpoints(this);\n tiles = new TileEndpoints(this);\n maps = new MapEndpoints(this);\n apiKeys = new ApiKeyEndpoints(this);\n applications = new ApplicationEndpoints(this);\n appconfig = new AppConfigEndpoints(this);\n contactpoints = new ContactPointEndpoints(this);\n databases = new DatabaseEndpoints(this);\n datasets = new DatasetEndpoints(this);\n styles = new StyleEndpoints(this);\n tileSources = new TileSourceEndpoints(this);\n uploads = new UploadEndpoints(this);\n jobs = new JobEndpoints(this);\n maplayers = new MapLayerEndpoints(this);\n media = new MediaEndpoints(this);\n pipelines = new PipelineEndpoints(this);\n\n useRequestInterceptor(interceptor: (config: any) => any) {\n return this.axios.interceptors.request.use(interceptor);\n }\n\n ejectRequestInterceptor(id: number) {\n this.axios.interceptors.request.eject(id);\n }\n\n constructor(public baseUrl: string, public readonly apiKey: string | null = null, options?: ClientOptions) {\n this.axios = Axios.create({\n baseURL: baseUrl,\n maxContentLength: 524288000,\n transformResponse: [\n function transformResponse(data, headers) {\n if (headers?.['content-type']?.startsWith('application/json')) {\n // Force parsing of data if expected content type is JSON\n // This ensures that errors are thrown if JSON is truncated due to a query timeout\n // (default Axios behavior is simply to return a string if JSON parsing fails)\n return JSON.parse(data);\n }\n\n return data;\n }\n ]\n });\n\n this.webSocketGateway = new WebSocketGateway(this, options);\n }\n\n connect(): Promise<void> {\n return this.webSocketGateway.connect();\n }\n\n disconnect(): Promise<void> {\n return this.webSocketGateway.disconnect();\n }\n\n config(): Promise<IConfig> {\n return this._get('/api/v1/config');\n }\n\n _get(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'get',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _post(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'post',\n url: path,\n data,\n maxContentLength: Infinity,\n maxBodyLength: Infinity,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _put(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'put',\n url: path,\n data,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _delete(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'delete',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n // Subscribe to named channel - errors and messages are delivered via the callback\n _subscribe(channel: string, cb: WebSocketSubscribeCallback): WebSocketUnsubscriber {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n\n return this.webSocketGateway.subscribe(channel, cb);\n }\n\n // Unsubscribe from named channel - optional callback is called on completion\n _unsubscribe(channel: string, cb?: WebSocketUnsubscribeCallback) {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n this.webSocketGateway.unsubscribe(channel, cb);\n }\n\n /**\n * Normalize errors\n * Throws a new error based on type of input error\n *\n * @param {AxiosError} e\n */\n private handleError(e: AxiosError) {\n // Flow API error\n if (e.response && e.response.data) {\n if (typeof e.response.data === 'object') {\n const data: any = e.response.data;\n throw new FlowEngineError(data.message || data.error, data.error, e.response.status);\n } else if (typeof e.response.data === 'string') {\n throw new FlowEngineError(e.response.data, null, e.response.status);\n }\n }\n\n // Generic error\n\n // Don't leak information in error\n const cleanError: any = e;\n delete cleanError.config;\n delete cleanError.request;\n delete cleanError.response;\n\n throw new FlowEngineError(cleanError.message, cleanError);\n }\n\n private headers(options: any) {\n const headers = options.headers || {};\n\n if (options.apiKey || this.apiKey) {\n headers['X-Api-Key'] = options.apiKey || this.apiKey;\n }\n\n // Add default auth header if token supplied and not already set in options\n if (this.accessToken) {\n headers.Authorization = headers.Authorization || `Bearer ${this.accessToken}`;\n }\n\n return { headers };\n }\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright © 2018-present Emu Analytics
|
|
4
|
+
*/
|
|
5
|
+
var __extends = (this && this.__extends) || (function () {
|
|
6
|
+
var extendStatics = function (d, b) {
|
|
7
|
+
extendStatics = Object.setPrototypeOf ||
|
|
8
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
9
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
10
|
+
return extendStatics(d, b);
|
|
11
|
+
};
|
|
12
|
+
return function (d, b) {
|
|
13
|
+
if (typeof b !== "function" && b !== null)
|
|
14
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
15
|
+
extendStatics(d, b);
|
|
16
|
+
function __() { this.constructor = d; }
|
|
17
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.ContactPointEndpoints = void 0;
|
|
22
|
+
var base_endpoints_1 = require("./base.endpoints");
|
|
23
|
+
var ContactPointEndpoints = /** @class */ (function (_super) {
|
|
24
|
+
__extends(ContactPointEndpoints, _super);
|
|
25
|
+
function ContactPointEndpoints(client) {
|
|
26
|
+
return _super.call(this, client, 'contactpoints') || this;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Send a notification to a contact point.
|
|
30
|
+
*/
|
|
31
|
+
ContactPointEndpoints.prototype.send = function (contactPointId, params) {
|
|
32
|
+
if (params === void 0) { params = {}; }
|
|
33
|
+
return this.client._post("".concat(this.resourceEndpoint, "/").concat(contactPointId, "/send"), params);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Get a list of available contact point drivers. Supported types include 'email', 'slack', 'teams', 'sns'.
|
|
37
|
+
*
|
|
38
|
+
* Drivers have different required parameters - refer to documentation for details.
|
|
39
|
+
*/
|
|
40
|
+
ContactPointEndpoints.prototype.drivers = function () {
|
|
41
|
+
return this.client._get("".concat(this.resourceEndpoint, "/drivers"));
|
|
42
|
+
};
|
|
43
|
+
return ContactPointEndpoints;
|
|
44
|
+
}(base_endpoints_1.BaseEndpoints));
|
|
45
|
+
exports.ContactPointEndpoints = ContactPointEndpoints;
|
|
46
|
+
//# sourceMappingURL=contact-point.endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-point.endpoints.js","sourceRoot":"","sources":["../../../src/lib/contact-point.endpoints.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;AAGH,mDAAiD;AAGjD;IAA2C,yCAA4B;IACrE,+BAAY,MAAc;QACxB,OAAA,MAAK,YAAC,MAAM,EAAE,eAAe,CAAC,SAAC;IACjC,CAAC;IAED;;OAEG;IACH,oCAAI,GAAJ,UAAK,cAAsB,EAAE,MAAqC;QAArC,uBAAA,EAAA,WAAqC;QAChE,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAG,IAAI,CAAC,gBAAgB,cAAI,cAAc,UAAO,EAAE,MAAM,CAAC,CAAC;IACtF,CAAC;IAED;;;;OAIG;IACH,uCAAO,GAAP;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAG,IAAI,CAAC,gBAAgB,aAAU,CAAC,CAAC;IAC9D,CAAC;IACH,4BAAC;AAAD,CAAC,AApBD,CAA2C,8BAAa,GAoBvD;AApBY,sDAAqB","sourcesContent":["/**\n * Copyright © 2018-present Emu Analytics\n */\n\nimport { IContactPoint, IContactPointSendRequest } from './api-interfaces';\nimport { BaseEndpoints } from './base.endpoints';\nimport { Client } from './client';\n\nexport class ContactPointEndpoints extends BaseEndpoints<IContactPoint> {\n constructor(client: Client) {\n super(client, 'contactpoints');\n }\n\n /**\n * Send a notification to a contact point.\n */\n send(contactPointId: string, params: IContactPointSendRequest = {}): Promise<void> {\n return this.client._post(`${this.resourceEndpoint}/${contactPointId}/send`, params);\n }\n\n /**\n * Get a list of available contact point drivers. Supported types include 'email', 'slack', 'teams', 'sns'.\n *\n * Drivers have different required parameters - refer to documentation for details.\n */\n drivers(): Promise<string[]> {\n return this.client._get(`${this.resourceEndpoint}/drivers`);\n }\n}\n"]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright © 2018-present Emu Analytics
|
|
4
|
+
*/
|
|
5
|
+
var __extends = (this && this.__extends) || (function () {
|
|
6
|
+
var extendStatics = function (d, b) {
|
|
7
|
+
extendStatics = Object.setPrototypeOf ||
|
|
8
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
9
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
10
|
+
return extendStatics(d, b);
|
|
11
|
+
};
|
|
12
|
+
return function (d, b) {
|
|
13
|
+
if (typeof b !== "function" && b !== null)
|
|
14
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
15
|
+
extendStatics(d, b);
|
|
16
|
+
function __() { this.constructor = d; }
|
|
17
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
30
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
31
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
32
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
33
|
+
function step(op) {
|
|
34
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
35
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
36
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
37
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
38
|
+
switch (op[0]) {
|
|
39
|
+
case 0: case 1: t = op; break;
|
|
40
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
41
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
42
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
43
|
+
default:
|
|
44
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
45
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
46
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
47
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
48
|
+
if (t[2]) _.ops.pop();
|
|
49
|
+
_.trys.pop(); continue;
|
|
50
|
+
}
|
|
51
|
+
op = body.call(thisArg, _);
|
|
52
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
53
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.MediaEndpoints = void 0;
|
|
61
|
+
var form_data_1 = __importDefault(require("form-data"));
|
|
62
|
+
var base_endpoints_1 = require("./base.endpoints");
|
|
63
|
+
var MediaEndpoints = /** @class */ (function (_super) {
|
|
64
|
+
__extends(MediaEndpoints, _super);
|
|
65
|
+
function MediaEndpoints(client) {
|
|
66
|
+
return _super.call(this, client, 'media') || this;
|
|
67
|
+
}
|
|
68
|
+
MediaEndpoints.prototype.upload = function (mediaId_1, request_1) {
|
|
69
|
+
return __awaiter(this, arguments, void 0, function (mediaId, request, params) {
|
|
70
|
+
var form, media;
|
|
71
|
+
var _a, _b;
|
|
72
|
+
if (params === void 0) { params = {}; }
|
|
73
|
+
return __generator(this, function (_c) {
|
|
74
|
+
switch (_c.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
form = new form_data_1.default();
|
|
77
|
+
form.append('id', mediaId);
|
|
78
|
+
if (request.type) {
|
|
79
|
+
form.append('type', request.type);
|
|
80
|
+
}
|
|
81
|
+
if (request.mimeType) {
|
|
82
|
+
form.append('mimeType', request.mimeType);
|
|
83
|
+
}
|
|
84
|
+
if (request.metadata) {
|
|
85
|
+
form.append('metadata', JSON.stringify(request.metadata));
|
|
86
|
+
}
|
|
87
|
+
form.append('file', request.data, request.fileName);
|
|
88
|
+
return [4 /*yield*/, this.client._post(this.resourceEndpoint, form, {
|
|
89
|
+
// Note - only Node FormData supports getHeaders
|
|
90
|
+
headers: (_b = (_a = form.getHeaders) === null || _a === void 0 ? void 0 : _a.call(form)) !== null && _b !== void 0 ? _b : { 'Content-Type': 'multipart/form-data' },
|
|
91
|
+
params: params
|
|
92
|
+
})];
|
|
93
|
+
case 1:
|
|
94
|
+
media = _c.sent();
|
|
95
|
+
return [2 /*return*/, media];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
MediaEndpoints.prototype.content = function (mediaId) {
|
|
101
|
+
return this.client._get("".concat(this.resourceEndpoint, "/").concat(mediaId, "/content"), { responseType: 'stream' });
|
|
102
|
+
};
|
|
103
|
+
return MediaEndpoints;
|
|
104
|
+
}(base_endpoints_1.BaseEndpoints));
|
|
105
|
+
exports.MediaEndpoints = MediaEndpoints;
|
|
106
|
+
//# sourceMappingURL=media.endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.endpoints.js","sourceRoot":"","sources":["../../../src/lib/media.endpoints.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wDAAiC;AAEjC,mDAAiD;AAWjD;IAAoC,kCAAqB;IACvD,wBAAY,MAAc;QACxB,OAAA,MAAK,YAAC,MAAM,EAAE,OAAO,CAAC,SAAC;IACzB,CAAC;IAEK,+BAAM,GAAZ;4DACE,OAAe,EACf,OAA4B,EAC5B,MAAgC;;;YAAhC,uBAAA,EAAA,WAAgC;;;;wBAE1B,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;wBAE5B,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;wBAE3B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;4BACjB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;wBACpC,CAAC;wBAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;4BACrB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;wBAC5C,CAAC;wBAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;4BACrB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAC5D,CAAC;wBAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;wBAE9B,qBAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE;gCACzE,gDAAgD;gCAChD,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,oDAAI,mCAAI,EAAE,cAAc,EAAE,qBAAqB,EAAE;gCACzE,MAAM,QAAA;6BACP,CAAC,EAAA;;wBAJI,KAAK,GAAW,SAIpB;wBAEF,sBAAO,KAAK,EAAC;;;;KACd;IAED,gCAAO,GAAP,UAAQ,OAAe;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAG,IAAI,CAAC,gBAAgB,cAAI,OAAO,aAAU,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrG,CAAC;IACH,qBAAC;AAAD,CAAC,AAxCD,CAAoC,8BAAa,GAwChD;AAxCY,wCAAc","sourcesContent":["/**\n * Copyright © 2018-present Emu Analytics\n */\n\nimport FormData from 'form-data';\nimport { IMedia, IMetadata } from './api-interfaces';\nimport { BaseEndpoints } from './base.endpoints';\nimport { Client } from './client';\n\ninterface IMediaUploadRequest {\n type: string;\n mimeType?: string;\n metadata?: IMetadata;\n fileName: string;\n data: any;\n}\n\nexport class MediaEndpoints extends BaseEndpoints<IMedia> {\n constructor(client: Client) {\n super(client, 'media');\n }\n\n async upload(\n mediaId: string,\n request: IMediaUploadRequest,\n params: Record<string, any> = {}\n ): Promise<IMedia> {\n const form = new FormData();\n\n form.append('id', mediaId);\n\n if (request.type) {\n form.append('type', request.type);\n }\n\n if (request.mimeType) {\n form.append('mimeType', request.mimeType);\n }\n\n if (request.metadata) {\n form.append('metadata', JSON.stringify(request.metadata));\n }\n\n form.append('file', request.data, request.fileName);\n\n const media: IMedia = await this.client._post(this.resourceEndpoint, form, {\n // Note - only Node FormData supports getHeaders\n headers: form.getHeaders?.() ?? { 'Content-Type': 'multipart/form-data' },\n params\n });\n\n return media;\n }\n\n content(mediaId: string): Promise<any> {\n return this.client._get(`${this.resourceEndpoint}/${mediaId}/content`, { responseType: 'stream' });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-interfaces.js","sourceRoot":"","sources":["../../../src/lib/api-interfaces.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nexport interface IQuery {\n filter?: { [key: string]: any };\n attributes?: string | string[];\n join?: string | string[];\n limit?: number;\n offset?: number;\n sort?: string | string[];\n}\n\nexport interface IBaseResource {\n id: string;\n}\n\nexport interface IMetadata {\n [key: string]: any;\n}\n\nexport interface IPermissions {\n [key: string]: { [key: string]: string };\n}\n\nexport interface IApiKey extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n description: string;\n type: 'app' | 'master';\n permissions: IPermissions;\n metadata: IMetadata;\n userId: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IApplication extends IBaseResource {\n id: string;\n name: string;\n databases?: IDatabase[];\n description: string;\n contact: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IAppConfig extends IBaseResource {\n applicationId: string;\n config: object;\n}\n\nexport interface IDatabase extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: string;\n name: string;\n default: boolean;\n description: string;\n host: string;\n port: number;\n user: string;\n password: string;\n db: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IDatasetAttribute {\n attribute: string;\n type: string;\n dbType: string;\n isGeometry?: boolean;\n srid?: number;\n extent?: number[];\n extentLngLat?: number[];\n primaryKey?: boolean;\n default?: string;\n nullable?: boolean;\n description?: string;\n}\n\nexport interface IDataset extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: 'table' | 'sql';\n source: string;\n name: string;\n databaseId: string;\n database?: IDatabase;\n description: string;\n bytes: number;\n metadata: IMetadata;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n attributes: IDatasetAttribute[];\n options?: { [key: string]: any };\n}\nexport interface IMapLayer extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n\n id: string;\n name: string;\n description: string;\n layerSpec: any;\n type: string;\n group: string;\n metadata: IMetadata;\n}\n\nexport type FileExportFormat = 'geojson' | 'gpkg' | 'shapefile';\n\nexport interface ITileSource extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n metadata: IMetadata;\n id: string;\n type: string;\n source: string;\n attribution: string;\n minZoom: number;\n maxZoom: number;\n headers: { [key: string]: string };\n extentLngLat: number[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IUpload extends IBaseResource {\n id: string;\n fileName: string;\n path: string;\n options: {\n name: string;\n description?: string;\n datasetId: string;\n attribution?: string;\n schema?: string;\n };\n size: number;\n status: string;\n error: { message: string; stdout: string; stderr: string };\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n updatedAt: string;\n createdAt: string;\n}\n\nexport interface IUser extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface IStyle extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface ITileSpec {\n [key: string]: any;\n}\n\nexport interface IConfig {\n version: {\n tag: string;\n hash: string;\n timestamp: number;\n };\n}\n\nexport interface ILoginResponse {\n accessToken: string;\n refreshToken: string;\n}\n\nexport interface ITokenRefreshResponse {\n accessToken: string;\n}\n\nexport interface UsersMeResponse {\n applicationId: string;\n email: string;\n firstName: string;\n id: string;\n lastName: string;\n metadata: object;\n roles: string[];\n}\n\n/* Job resource */\nexport type JobStatus = 'pending' | 'processing' | 'done' | 'cancelled' | 'error';\n\nexport interface IJob {\n id: string;\n applicationId: string;\n ownerId?: string;\n metadata: IMetadata;\n type: string;\n name?: string;\n description?: string;\n params: any;\n status: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n datasetId?: string;\n createdAt: string;\n updatedAt: string;\n}\nexport interface IJobStatus {\n status?: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n}\n\nexport interface IJobSubmission {\n type: string;\n name?: string;\n description?: string;\n params: any;\n}\n\nexport interface IJobRequest {\n type: string;\n}\n\nexport type IngestAction = 'insert' | 'upsert' | 'delete';\nexport interface IIngestMessage {\n datasetId: string;\n action: IngestAction;\n data: any;\n}\n\nexport interface IPipeline extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n environment: string;\n description: string;\n config: Record<string, any>;\n metadata: IMetadata;\n startedAt: string;\n heartbeatAt: string;\n createdAt: string;\n updatedAt: string;\n components?: IPipelineComponent[];\n}\n\nexport interface IPipelineComponent extends IBaseResource {\n id: string;\n description: string;\n config: Record<string, any>;\n class: string;\n type: string;\n metadata: IMetadata;\n index: number;\n createdAt: string;\n updatedAt: string;\n metrics?: IPipelineMetric[];\n}\n\nexport interface IPipelineMetric extends IBaseResource {\n id: string;\n applicationId: string;\n pipelineId: string;\n componentId: string;\n name: string;\n type: string;\n timestamp: string;\n value: number;\n labels: Record<string, string>;\n createdAt: string;\n updatedAt: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api-interfaces.js","sourceRoot":"","sources":["../../../src/lib/api-interfaces.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nexport interface IQuery {\n filter?: { [key: string]: any };\n attributes?: string | string[];\n join?: string | string[];\n limit?: number;\n offset?: number;\n sort?: string | string[];\n}\n\nexport interface IBaseResource {\n id: string;\n}\n\nexport interface IMetadata {\n [key: string]: any;\n}\n\nexport interface IPermissions {\n [key: string]: { [key: string]: string };\n}\n\nexport interface IApiKey extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n description: string;\n type: 'app' | 'master';\n permissions: IPermissions;\n metadata: IMetadata;\n userId: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IApplication extends IBaseResource {\n id: string;\n name: string;\n databases?: IDatabase[];\n description: string;\n contact: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IAppConfig extends IBaseResource {\n applicationId: string;\n config: object;\n}\n\nexport interface IDatabase extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: string;\n name: string;\n default: boolean;\n description: string;\n host: string;\n port: number;\n user: string;\n password: string;\n db: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IDatasetAttribute {\n attribute: string;\n type: string;\n dbType: string;\n isGeometry?: boolean;\n srid?: number;\n extent?: number[];\n extentLngLat?: number[];\n primaryKey?: boolean;\n default?: string;\n nullable?: boolean;\n description?: string;\n}\n\nexport interface IDataset extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n type: 'table' | 'sql';\n source: string;\n name: string;\n databaseId: string;\n database?: IDatabase;\n description: string;\n bytes: number;\n metadata: IMetadata;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n attributes: IDatasetAttribute[];\n options?: { [key: string]: any };\n}\nexport interface IMapLayer extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n createdAt: string;\n updatedAt: string;\n\n id: string;\n name: string;\n description: string;\n layerSpec: any;\n type: string;\n group: string;\n metadata: IMetadata;\n}\n\nexport type FileExportFormat = 'geojson' | 'gpkg' | 'shapefile';\n\nexport interface ITileSource extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n metadata: IMetadata;\n id: string;\n type: string;\n source: string;\n attribution: string;\n minZoom: number;\n maxZoom: number;\n headers: { [key: string]: string };\n extentLngLat: number[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface IUpload extends IBaseResource {\n id: string;\n fileName: string;\n path: string;\n options: {\n name: string;\n description?: string;\n datasetId: string;\n attribution?: string;\n schema?: string;\n };\n size: number;\n status: string;\n error: { message: string; stdout: string; stderr: string };\n applicationId: string;\n application?: IApplication;\n ownerId: string;\n updatedAt: string;\n createdAt: string;\n}\n\nexport interface IUser extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface IStyle extends IBaseResource {\n [key: string]: any;\n}\n\nexport interface ITileSpec {\n [key: string]: any;\n}\n\nexport interface IConfig {\n version: {\n tag: string;\n hash: string;\n timestamp: number;\n };\n}\n\nexport interface ILoginResponse {\n accessToken: string;\n refreshToken: string;\n}\n\nexport interface ITokenRefreshResponse {\n accessToken: string;\n}\n\nexport interface UsersMeResponse {\n applicationId: string;\n email: string;\n firstName: string;\n id: string;\n lastName: string;\n metadata: object;\n roles: string[];\n}\n\n/* Job resource */\nexport type JobStatus = 'pending' | 'processing' | 'done' | 'cancelled' | 'error';\n\nexport interface IJob {\n id: string;\n applicationId: string;\n ownerId?: string;\n metadata: IMetadata;\n type: string;\n name?: string;\n description?: string;\n params: any;\n status: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n datasetId?: string;\n createdAt: string;\n updatedAt: string;\n}\nexport interface IJobStatus {\n status?: JobStatus;\n error?: object;\n progress?: number;\n progressText?: string;\n}\n\nexport interface IJobSubmission {\n type: string;\n name?: string;\n description?: string;\n params: any;\n}\n\nexport interface IJobRequest {\n type: string;\n}\n\nexport type IngestAction = 'insert' | 'upsert' | 'delete';\nexport interface IIngestMessage {\n datasetId: string;\n action: IngestAction;\n data: any;\n}\n\nexport interface IPipeline extends IBaseResource {\n applicationId: string;\n application?: IApplication;\n id: string;\n environment: string;\n description: string;\n config: Record<string, any>;\n metadata: IMetadata;\n startedAt: string;\n heartbeatAt: string;\n createdAt: string;\n updatedAt: string;\n components?: IPipelineComponent[];\n}\n\nexport interface IPipelineComponent extends IBaseResource {\n id: string;\n description: string;\n config: Record<string, any>;\n class: string;\n type: string;\n metadata: IMetadata;\n index: number;\n createdAt: string;\n updatedAt: string;\n metrics?: IPipelineMetric[];\n}\n\nexport interface IPipelineMetric extends IBaseResource {\n id: string;\n applicationId: string;\n pipelineId: string;\n componentId: string;\n name: string;\n type: string;\n timestamp: string;\n value: number;\n labels: Record<string, string>;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Contact point resource.\n */\nexport interface IContactPoint extends IBaseResource {\n id: string;\n applicationId: string;\n type: string;\n description: string;\n templates: string[];\n recipients: string[];\n /** Driver-specific host configuration for the contact point */\n host: string;\n /** Driver-specific port configuration for the contact point */\n port: number;\n /** Driver-specific user configuration for the contact point */\n user: string;\n /** Driver-specific password configuration for the contact point */\n password: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Request body for sending a notification to a contact point.\n */\nexport interface IContactPointSendRequest {\n /** ID of the template to use for the notification */\n template?: string;\n /** Subject of the notification */\n subject?: string;\n /** Recipients of the notification */\n recipients?: string[];\n /** Template key/value data for expanding the notification template */\n data?: any;\n}\n\n/**\n * Media resource.\n */\nexport interface IMedia extends IBaseResource {\n id: string;\n applicationId: string;\n type: string;\n mimeType: string;\n fileName: string;\n metadata: IMetadata;\n createdAt: string;\n updatedAt: string;\n}\n"]}
|
package/dist/esm/lib/client.js
CHANGED
|
@@ -18,12 +18,14 @@ import { ApiKeyEndpoints } from './apikey.endpoints';
|
|
|
18
18
|
import { AppConfigEndpoints } from './appconfig.endpoints';
|
|
19
19
|
import { ApplicationEndpoints } from './application.endpoints';
|
|
20
20
|
import { AuthEndpoints } from './auth.edpoints';
|
|
21
|
+
import { ContactPointEndpoints } from './contact-point.endpoints';
|
|
21
22
|
import { DatabaseEndpoints } from './database.endpoints';
|
|
22
23
|
import { DatasetEndpoints } from './dataset.endpoints';
|
|
23
24
|
import { FlowEngineError } from './errors';
|
|
24
25
|
import { JobEndpoints } from './job.endpoints';
|
|
25
26
|
import { MapEndpoints } from './map.endoints';
|
|
26
27
|
import { MapLayerEndpoints } from './maplayer.endpoints';
|
|
28
|
+
import { MediaEndpoints } from './media.endpoints';
|
|
27
29
|
import { PipelineEndpoints } from './pipeline.endpoints';
|
|
28
30
|
import { StyleEndpoints } from './style.endpoint';
|
|
29
31
|
import { TileSourceEndpoints } from './tile-source.endpoints';
|
|
@@ -43,6 +45,7 @@ var Client = /** @class */ (function () {
|
|
|
43
45
|
this.apiKeys = new ApiKeyEndpoints(this);
|
|
44
46
|
this.applications = new ApplicationEndpoints(this);
|
|
45
47
|
this.appconfig = new AppConfigEndpoints(this);
|
|
48
|
+
this.contactpoints = new ContactPointEndpoints(this);
|
|
46
49
|
this.databases = new DatabaseEndpoints(this);
|
|
47
50
|
this.datasets = new DatasetEndpoints(this);
|
|
48
51
|
this.styles = new StyleEndpoints(this);
|
|
@@ -50,6 +53,7 @@ var Client = /** @class */ (function () {
|
|
|
50
53
|
this.uploads = new UploadEndpoints(this);
|
|
51
54
|
this.jobs = new JobEndpoints(this);
|
|
52
55
|
this.maplayers = new MapLayerEndpoints(this);
|
|
56
|
+
this.media = new MediaEndpoints(this);
|
|
53
57
|
this.pipelines = new PipelineEndpoints(this);
|
|
54
58
|
this.axios = Axios.create({
|
|
55
59
|
baseURL: baseUrl,
|
|
@@ -69,6 +73,12 @@ var Client = /** @class */ (function () {
|
|
|
69
73
|
});
|
|
70
74
|
this.webSocketGateway = new WebSocketGateway(this, options);
|
|
71
75
|
}
|
|
76
|
+
Client.prototype.useRequestInterceptor = function (interceptor) {
|
|
77
|
+
return this.axios.interceptors.request.use(interceptor);
|
|
78
|
+
};
|
|
79
|
+
Client.prototype.ejectRequestInterceptor = function (id) {
|
|
80
|
+
this.axios.interceptors.request.eject(id);
|
|
81
|
+
};
|
|
72
82
|
Client.prototype.connect = function () {
|
|
73
83
|
return this.webSocketGateway.connect();
|
|
74
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;AAEH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AAC,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,gBAAgB;QAEhB,kCAAkC;QAClC,IAAM,UAAU,GAAQ,CAAC,CAAC;QAC1B,OAAO,UAAU,CAAC,MAAM,CAAC;QACzB,OAAO,UAAU,CAAC,OAAO,CAAC;QAC1B,OAAO,UAAU,CAAC,QAAQ,CAAC;QAE3B,MAAM,IAAI,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IAEO,wBAAO,GAAf,UAAgB,OAAY;QAC1B,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QAEtC,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QACvD,CAAC;QAED,2EAA2E;QAC3E,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,iBAAU,IAAI,CAAC,WAAW,CAAE,CAAC;QAChF,CAAC;QAED,OAAO,EAAE,OAAO,SAAA,EAAE,CAAC;IACrB,CAAC;IACH,aAAC;AAAD,CAAC,AA3LD,IA2LC","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nimport Axios, { AxiosError, AxiosInstance } from 'axios';\nimport Debug from 'debug';\nimport { IConfig } from './api-interfaces';\nimport { ApiKeyEndpoints } from './apikey.endpoints';\nimport { AppConfigEndpoints } from './appconfig.endpoints';\nimport { ApplicationEndpoints } from './application.endpoints';\nimport { AuthEndpoints } from './auth.edpoints';\nimport { DatabaseEndpoints } from './database.endpoints';\nimport { DatasetEndpoints } from './dataset.endpoints';\nimport { FlowEngineError } from './errors';\nimport { JobEndpoints } from './job.endpoints';\nimport { MapEndpoints } from './map.endoints';\nimport { MapLayerEndpoints } from './maplayer.endpoints';\nimport { PipelineEndpoints } from './pipeline.endpoints';\nimport { StyleEndpoints } from './style.endpoint';\nimport { TileSourceEndpoints } from './tile-source.endpoints';\nimport { TileEndpoints } from './tile.endpoints';\nimport { UploadEndpoints } from './upload.endpoints';\nimport {\n WebSocketGateway,\n WebSocketManagerOptions,\n WebSocketSubscribeCallback,\n WebSocketUnsubscribeCallback,\n WebSocketUnsubscriber\n} from './web-socket-gateway';\n\nexport type ClientOptions = WebSocketManagerOptions;\n\nexport class Client {\n private readonly axios: AxiosInstance;\n readonly debug = Debug('flow-engine-client');\n\n public webSocketGateway: WebSocketGateway;\n\n accessToken: string | null = null;\n\n auth = new AuthEndpoints(this);\n tiles = new TileEndpoints(this);\n maps = new MapEndpoints(this);\n apiKeys = new ApiKeyEndpoints(this);\n applications = new ApplicationEndpoints(this);\n appconfig = new AppConfigEndpoints(this);\n databases = new DatabaseEndpoints(this);\n datasets = new DatasetEndpoints(this);\n styles = new StyleEndpoints(this);\n tileSources = new TileSourceEndpoints(this);\n uploads = new UploadEndpoints(this);\n jobs = new JobEndpoints(this);\n maplayers = new MapLayerEndpoints(this);\n pipelines = new PipelineEndpoints(this);\n\n constructor(public baseUrl: string, public readonly apiKey: string | null = null, options?: ClientOptions) {\n this.axios = Axios.create({\n baseURL: baseUrl,\n maxContentLength: 524288000,\n transformResponse: [\n function transformResponse(data, headers) {\n if (headers?.['content-type']?.startsWith('application/json')) {\n // Force parsing of data if expected content type is JSON\n // This ensures that errors are thrown if JSON is truncated due to a query timeout\n // (default Axios behavior is simply to return a string if JSON parsing fails)\n return JSON.parse(data);\n }\n\n return data;\n }\n ]\n });\n\n this.webSocketGateway = new WebSocketGateway(this, options);\n }\n\n connect(): Promise<void> {\n return this.webSocketGateway.connect();\n }\n\n disconnect(): Promise<void> {\n return this.webSocketGateway.disconnect();\n }\n\n config(): Promise<IConfig> {\n return this._get('/api/v1/config');\n }\n\n _get(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'get',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _post(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'post',\n url: path,\n data,\n maxContentLength: Infinity,\n maxBodyLength: Infinity,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _put(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'put',\n url: path,\n data,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _delete(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'delete',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n // Subscribe to named channel - errors and messages are delivered via the callback\n _subscribe(channel: string, cb: WebSocketSubscribeCallback): WebSocketUnsubscriber {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n\n return this.webSocketGateway.subscribe(channel, cb);\n }\n\n // Unsubscribe from named channel - optional callback is called on completion\n _unsubscribe(channel: string, cb?: WebSocketUnsubscribeCallback) {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n this.webSocketGateway.unsubscribe(channel, cb);\n }\n\n /**\n * Normalize errors\n * Throws a new error based on type of input error\n *\n * @param {AxiosError} e\n */\n private handleError(e: AxiosError) {\n // Flow API error\n if (e.response && e.response.data) {\n if (typeof e.response.data === 'object') {\n const data: any = e.response.data;\n throw new FlowEngineError(data.message || data.error, data.error, e.response.status);\n } else if (typeof e.response.data === 'string') {\n throw new FlowEngineError(e.response.data, null, e.response.status);\n }\n }\n\n // Generic error\n\n // Don't leak information in error\n const cleanError: any = e;\n delete cleanError.config;\n delete cleanError.request;\n delete cleanError.response;\n\n throw new FlowEngineError(cleanError.message, cleanError);\n }\n\n private headers(options: any) {\n const headers = options.headers || {};\n\n if (options.apiKey || this.apiKey) {\n headers['X-Api-Key'] = options.apiKey || this.apiKey;\n }\n\n // Add default auth header if token supplied and not already set in options\n if (this.accessToken) {\n headers.Authorization = headers.Authorization || `Bearer ${this.accessToken}`;\n }\n\n return { headers };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;AAEH,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cA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CAAC;QAC1B,OAAO,UAAU,CAAC,MAAM,CAAC;QACzB,OAAO,UAAU,CAAC,OAAO,CAAC;QAC1B,OAAO,UAAU,CAAC,QAAQ,CAAC;QAE3B,MAAM,IAAI,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IAEO,wBAAO,GAAf,UAAgB,OAAY;QAC1B,IAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QAEtC,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QACvD,CAAC;QAED,2EAA2E;QAC3E,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,iBAAU,IAAI,CAAC,WAAW,CAAE,CAAC;QAChF,CAAC;QAED,OAAO,EAAE,OAAO,SAAA,EAAE,CAAC;IACrB,CAAC;IACH,aAAC;AAAD,CAAC,AArMD,IAqMC","sourcesContent":["/**\n * Copyright © 2018 Emu Analytics\n */\n\nimport Axios, { AxiosError, AxiosInstance } from 'axios';\nimport Debug from 'debug';\nimport { IConfig } from './api-interfaces';\nimport { ApiKeyEndpoints } from './apikey.endpoints';\nimport { AppConfigEndpoints } from './appconfig.endpoints';\nimport { ApplicationEndpoints } from './application.endpoints';\nimport { AuthEndpoints } from './auth.edpoints';\nimport { ContactPointEndpoints } from './contact-point.endpoints';\nimport { DatabaseEndpoints } from './database.endpoints';\nimport { DatasetEndpoints } from './dataset.endpoints';\nimport { FlowEngineError } from './errors';\nimport { JobEndpoints } from './job.endpoints';\nimport { MapEndpoints } from './map.endoints';\nimport { MapLayerEndpoints } from './maplayer.endpoints';\nimport { MediaEndpoints } from './media.endpoints';\nimport { PipelineEndpoints } from './pipeline.endpoints';\nimport { StyleEndpoints } from './style.endpoint';\nimport { TileSourceEndpoints } from './tile-source.endpoints';\nimport { TileEndpoints } from './tile.endpoints';\nimport { UploadEndpoints } from './upload.endpoints';\nimport {\n WebSocketGateway,\n WebSocketManagerOptions,\n WebSocketSubscribeCallback,\n WebSocketUnsubscribeCallback,\n WebSocketUnsubscriber\n} from './web-socket-gateway';\n\nexport type ClientOptions = WebSocketManagerOptions;\n\nexport class Client {\n private readonly axios: AxiosInstance;\n readonly debug = Debug('flow-engine-client');\n\n public webSocketGateway: WebSocketGateway;\n\n accessToken: string | null = null;\n\n auth = new AuthEndpoints(this);\n tiles = new TileEndpoints(this);\n maps = new MapEndpoints(this);\n apiKeys = new ApiKeyEndpoints(this);\n applications = new ApplicationEndpoints(this);\n appconfig = new AppConfigEndpoints(this);\n contactpoints = new ContactPointEndpoints(this);\n databases = new DatabaseEndpoints(this);\n datasets = new DatasetEndpoints(this);\n styles = new StyleEndpoints(this);\n tileSources = new TileSourceEndpoints(this);\n uploads = new UploadEndpoints(this);\n jobs = new JobEndpoints(this);\n maplayers = new MapLayerEndpoints(this);\n media = new MediaEndpoints(this);\n pipelines = new PipelineEndpoints(this);\n\n useRequestInterceptor(interceptor: (config: any) => any) {\n return this.axios.interceptors.request.use(interceptor);\n }\n\n ejectRequestInterceptor(id: number) {\n this.axios.interceptors.request.eject(id);\n }\n\n constructor(public baseUrl: string, public readonly apiKey: string | null = null, options?: ClientOptions) {\n this.axios = Axios.create({\n baseURL: baseUrl,\n maxContentLength: 524288000,\n transformResponse: [\n function transformResponse(data, headers) {\n if (headers?.['content-type']?.startsWith('application/json')) {\n // Force parsing of data if expected content type is JSON\n // This ensures that errors are thrown if JSON is truncated due to a query timeout\n // (default Axios behavior is simply to return a string if JSON parsing fails)\n return JSON.parse(data);\n }\n\n return data;\n }\n ]\n });\n\n this.webSocketGateway = new WebSocketGateway(this, options);\n }\n\n connect(): Promise<void> {\n return this.webSocketGateway.connect();\n }\n\n disconnect(): Promise<void> {\n return this.webSocketGateway.disconnect();\n }\n\n config(): Promise<IConfig> {\n return this._get('/api/v1/config');\n }\n\n _get(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'get',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _post(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'post',\n url: path,\n data,\n maxContentLength: Infinity,\n maxBodyLength: Infinity,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _put(path: string, data: object, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'put',\n url: path,\n data,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n _delete(path: string, options: any = {}): Promise<any> {\n // Move apiKey from params\n if (options.params?.apiKey) {\n options.apiKey = options.params.apiKey;\n delete options.params.apiKey;\n }\n\n return this.axios({\n method: 'delete',\n url: path,\n ...options,\n ...this.headers(options)\n })\n .then(res => res.data)\n .catch(this.handleError);\n }\n\n // Subscribe to named channel - errors and messages are delivered via the callback\n _subscribe(channel: string, cb: WebSocketSubscribeCallback): WebSocketUnsubscriber {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n\n return this.webSocketGateway.subscribe(channel, cb);\n }\n\n // Unsubscribe from named channel - optional callback is called on completion\n _unsubscribe(channel: string, cb?: WebSocketUnsubscribeCallback) {\n if (!this.webSocketGateway.isConnected) {\n this.webSocketGateway.connect();\n }\n this.webSocketGateway.unsubscribe(channel, cb);\n }\n\n /**\n * Normalize errors\n * Throws a new error based on type of input error\n *\n * @param {AxiosError} e\n */\n private handleError(e: AxiosError) {\n // Flow API error\n if (e.response && e.response.data) {\n if (typeof e.response.data === 'object') {\n const data: any = e.response.data;\n throw new FlowEngineError(data.message || data.error, data.error, e.response.status);\n } else if (typeof e.response.data === 'string') {\n throw new FlowEngineError(e.response.data, null, e.response.status);\n }\n }\n\n // Generic error\n\n // Don't leak information in error\n const cleanError: any = e;\n delete cleanError.config;\n delete cleanError.request;\n delete cleanError.response;\n\n throw new FlowEngineError(cleanError.message, cleanError);\n }\n\n private headers(options: any) {\n const headers = options.headers || {};\n\n if (options.apiKey || this.apiKey) {\n headers['X-Api-Key'] = options.apiKey || this.apiKey;\n }\n\n // Add default auth header if token supplied and not already set in options\n if (this.accessToken) {\n headers.Authorization = headers.Authorization || `Bearer ${this.accessToken}`;\n }\n\n return { headers };\n }\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © 2018-present Emu Analytics
|
|
3
|
+
*/
|
|
4
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics = Object.setPrototypeOf ||
|
|
7
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
+
return extendStatics(d, b);
|
|
10
|
+
};
|
|
11
|
+
return function (d, b) {
|
|
12
|
+
if (typeof b !== "function" && b !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
+
extendStatics(d, b);
|
|
15
|
+
function __() { this.constructor = d; }
|
|
16
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
import { BaseEndpoints } from './base.endpoints';
|
|
20
|
+
var ContactPointEndpoints = /** @class */ (function (_super) {
|
|
21
|
+
__extends(ContactPointEndpoints, _super);
|
|
22
|
+
function ContactPointEndpoints(client) {
|
|
23
|
+
return _super.call(this, client, 'contactpoints') || this;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Send a notification to a contact point.
|
|
27
|
+
*/
|
|
28
|
+
ContactPointEndpoints.prototype.send = function (contactPointId, params) {
|
|
29
|
+
if (params === void 0) { params = {}; }
|
|
30
|
+
return this.client._post("".concat(this.resourceEndpoint, "/").concat(contactPointId, "/send"), params);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Get a list of available contact point drivers. Supported types include 'email', 'slack', 'teams', 'sns'.
|
|
34
|
+
*
|
|
35
|
+
* Drivers have different required parameters - refer to documentation for details.
|
|
36
|
+
*/
|
|
37
|
+
ContactPointEndpoints.prototype.drivers = function () {
|
|
38
|
+
return this.client._get("".concat(this.resourceEndpoint, "/drivers"));
|
|
39
|
+
};
|
|
40
|
+
return ContactPointEndpoints;
|
|
41
|
+
}(BaseEndpoints));
|
|
42
|
+
export { ContactPointEndpoints };
|
|
43
|
+
//# sourceMappingURL=contact-point.endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-point.endpoints.js","sourceRoot":"","sources":["../../../src/lib/contact-point.endpoints.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD;IAA2C,yCAA4B;IACrE,+BAAY,MAAc;QACxB,OAAA,MAAK,YAAC,MAAM,EAAE,eAAe,CAAC,SAAC;IACjC,CAAC;IAED;;OAEG;IACH,oCAAI,GAAJ,UAAK,cAAsB,EAAE,MAAqC;QAArC,uBAAA,EAAA,WAAqC;QAChE,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAG,IAAI,CAAC,gBAAgB,cAAI,cAAc,UAAO,EAAE,MAAM,CAAC,CAAC;IACtF,CAAC;IAED;;;;OAIG;IACH,uCAAO,GAAP;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAG,IAAI,CAAC,gBAAgB,aAAU,CAAC,CAAC;IAC9D,CAAC;IACH,4BAAC;AAAD,CAAC,AApBD,CAA2C,aAAa,GAoBvD","sourcesContent":["/**\n * Copyright © 2018-present Emu Analytics\n */\n\nimport { IContactPoint, IContactPointSendRequest } from './api-interfaces';\nimport { BaseEndpoints } from './base.endpoints';\nimport { Client } from './client';\n\nexport class ContactPointEndpoints extends BaseEndpoints<IContactPoint> {\n constructor(client: Client) {\n super(client, 'contactpoints');\n }\n\n /**\n * Send a notification to a contact point.\n */\n send(contactPointId: string, params: IContactPointSendRequest = {}): Promise<void> {\n return this.client._post(`${this.resourceEndpoint}/${contactPointId}/send`, params);\n }\n\n /**\n * Get a list of available contact point drivers. Supported types include 'email', 'slack', 'teams', 'sns'.\n *\n * Drivers have different required parameters - refer to documentation for details.\n */\n drivers(): Promise<string[]> {\n return this.client._get(`${this.resourceEndpoint}/drivers`);\n }\n}\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © 2018-present Emu Analytics
|
|
3
|
+
*/
|
|
4
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics = Object.setPrototypeOf ||
|
|
7
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
+
return extendStatics(d, b);
|
|
10
|
+
};
|
|
11
|
+
return function (d, b) {
|
|
12
|
+
if (typeof b !== "function" && b !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
+
extendStatics(d, b);
|
|
15
|
+
function __() { this.constructor = d; }
|
|
16
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
30
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
+
function step(op) {
|
|
33
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
+
switch (op[0]) {
|
|
38
|
+
case 0: case 1: t = op; break;
|
|
39
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
+
default:
|
|
43
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
+
if (t[2]) _.ops.pop();
|
|
48
|
+
_.trys.pop(); continue;
|
|
49
|
+
}
|
|
50
|
+
op = body.call(thisArg, _);
|
|
51
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
import FormData from 'form-data';
|
|
56
|
+
import { BaseEndpoints } from './base.endpoints';
|
|
57
|
+
var MediaEndpoints = /** @class */ (function (_super) {
|
|
58
|
+
__extends(MediaEndpoints, _super);
|
|
59
|
+
function MediaEndpoints(client) {
|
|
60
|
+
return _super.call(this, client, 'media') || this;
|
|
61
|
+
}
|
|
62
|
+
MediaEndpoints.prototype.upload = function (mediaId_1, request_1) {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function (mediaId, request, params) {
|
|
64
|
+
var form, media;
|
|
65
|
+
var _a, _b;
|
|
66
|
+
if (params === void 0) { params = {}; }
|
|
67
|
+
return __generator(this, function (_c) {
|
|
68
|
+
switch (_c.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
form = new FormData();
|
|
71
|
+
form.append('id', mediaId);
|
|
72
|
+
if (request.type) {
|
|
73
|
+
form.append('type', request.type);
|
|
74
|
+
}
|
|
75
|
+
if (request.mimeType) {
|
|
76
|
+
form.append('mimeType', request.mimeType);
|
|
77
|
+
}
|
|
78
|
+
if (request.metadata) {
|
|
79
|
+
form.append('metadata', JSON.stringify(request.metadata));
|
|
80
|
+
}
|
|
81
|
+
form.append('file', request.data, request.fileName);
|
|
82
|
+
return [4 /*yield*/, this.client._post(this.resourceEndpoint, form, {
|
|
83
|
+
// Note - only Node FormData supports getHeaders
|
|
84
|
+
headers: (_b = (_a = form.getHeaders) === null || _a === void 0 ? void 0 : _a.call(form)) !== null && _b !== void 0 ? _b : { 'Content-Type': 'multipart/form-data' },
|
|
85
|
+
params: params
|
|
86
|
+
})];
|
|
87
|
+
case 1:
|
|
88
|
+
media = _c.sent();
|
|
89
|
+
return [2 /*return*/, media];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
MediaEndpoints.prototype.content = function (mediaId) {
|
|
95
|
+
return this.client._get("".concat(this.resourceEndpoint, "/").concat(mediaId, "/content"), { responseType: 'stream' });
|
|
96
|
+
};
|
|
97
|
+
return MediaEndpoints;
|
|
98
|
+
}(BaseEndpoints));
|
|
99
|
+
export { MediaEndpoints };
|
|
100
|
+
//# sourceMappingURL=media.endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.endpoints.js","sourceRoot":"","sources":["../../../src/lib/media.endpoints.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAWjD;IAAoC,kCAAqB;IACvD,wBAAY,MAAc;QACxB,OAAA,MAAK,YAAC,MAAM,EAAE,OAAO,CAAC,SAAC;IACzB,CAAC;IAEK,+BAAM,GAAZ;4DACE,OAAe,EACf,OAA4B,EAC5B,MAAgC;;;YAAhC,uBAAA,EAAA,WAAgC;;;;wBAE1B,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;wBAE5B,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;wBAE3B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;4BACjB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;wBACpC,CAAC;wBAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;4BACrB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;wBAC5C,CAAC;wBAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;4BACrB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAC5D,CAAC;wBAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;wBAE9B,qBAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE;gCACzE,gDAAgD;gCAChD,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,oDAAI,mCAAI,EAAE,cAAc,EAAE,qBAAqB,EAAE;gCACzE,MAAM,QAAA;6BACP,CAAC,EAAA;;wBAJI,KAAK,GAAW,SAIpB;wBAEF,sBAAO,KAAK,EAAC;;;;KACd;IAED,gCAAO,GAAP,UAAQ,OAAe;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAG,IAAI,CAAC,gBAAgB,cAAI,OAAO,aAAU,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrG,CAAC;IACH,qBAAC;AAAD,CAAC,AAxCD,CAAoC,aAAa,GAwChD","sourcesContent":["/**\n * Copyright © 2018-present Emu Analytics\n */\n\nimport FormData from 'form-data';\nimport { IMedia, IMetadata } from './api-interfaces';\nimport { BaseEndpoints } from './base.endpoints';\nimport { Client } from './client';\n\ninterface IMediaUploadRequest {\n type: string;\n mimeType?: string;\n metadata?: IMetadata;\n fileName: string;\n data: any;\n}\n\nexport class MediaEndpoints extends BaseEndpoints<IMedia> {\n constructor(client: Client) {\n super(client, 'media');\n }\n\n async upload(\n mediaId: string,\n request: IMediaUploadRequest,\n params: Record<string, any> = {}\n ): Promise<IMedia> {\n const form = new FormData();\n\n form.append('id', mediaId);\n\n if (request.type) {\n form.append('type', request.type);\n }\n\n if (request.mimeType) {\n form.append('mimeType', request.mimeType);\n }\n\n if (request.metadata) {\n form.append('metadata', JSON.stringify(request.metadata));\n }\n\n form.append('file', request.data, request.fileName);\n\n const media: IMedia = await this.client._post(this.resourceEndpoint, form, {\n // Note - only Node FormData supports getHeaders\n headers: form.getHeaders?.() ?? { 'Content-Type': 'multipart/form-data' },\n params\n });\n\n return media;\n }\n\n content(mediaId: string): Promise<any> {\n return this.client._get(`${this.resourceEndpoint}/${mediaId}/content`, { responseType: 'stream' });\n }\n}\n"]}
|