feat: remoteResource support headers setting

This commit is contained in:
pengfei.zhou 2023-09-22 14:24:39 +08:00 committed by jingpeng
parent f8f7ff9a6b
commit 2c52403d5f
7 changed files with 48 additions and 0 deletions

View File

@ -2183,6 +2183,19 @@ var __extends$g = (undefined && undefined.__extends) || (function () {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign$1 = (undefined && undefined.__assign) || function () {
__assign$1 = Object.assign || function(t) {
var arguments$1 = arguments;
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments$1[i];
for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p))
{ t[p] = s[p]; } }
}
return t;
};
return __assign$1.apply(this, arguments);
};
var Resource = /** @class */ (function () {
function Resource(type, identifier) {
this.resId = uniqueId("resource");
@ -2210,6 +2223,9 @@ var RemoteResource = /** @class */ (function (_super) {
function RemoteResource(url) {
return _super.call(this, "remote", url) || this;
}
RemoteResource.prototype.toModel = function () {
return __assign$1(__assign$1({}, _super.prototype.toModel.call(this)), { headers: this.headers });
};
return RemoteResource;
}(Resource));
var Base64Resource = /** @class */ (function (_super) {

View File

@ -1670,6 +1670,9 @@ class RemoteResource extends Resource {
constructor(url) {
super("remote", url);
}
toModel() {
return Object.assign(Object.assign({}, super.toModel()), { headers: this.headers });
}
}
class Base64Resource extends Resource {
constructor(content) {

View File

@ -3211,6 +3211,9 @@ class RemoteResource extends Resource {
constructor(url) {
super("remote", url);
}
toModel() {
return Object.assign(Object.assign({}, super.toModel()), { headers: this.headers });
}
}
class Base64Resource extends Resource {
constructor(content) {

7
doric-js/index.d.ts vendored
View File

@ -821,7 +821,14 @@ declare module "doric" {
constructor(path: string);
}
export class RemoteResource extends Resource {
headers?: Record<string, string>;
constructor(url: string);
toModel(): {
headers: Record<string, string> | undefined;
resId: string;
type: string;
identifier: string;
};
}
export class Base64Resource extends Resource {
constructor(content: string);

View File

@ -14,7 +14,14 @@ export declare class LocalResource extends Resource {
constructor(path: string);
}
export declare class RemoteResource extends Resource {
headers?: Record<string, string>;
constructor(url: string);
toModel(): {
headers: Record<string, string> | undefined;
resId: string;
type: string;
identifier: string;
};
}
export declare class Base64Resource extends Resource {
constructor(content: string);

View File

@ -22,6 +22,9 @@ export class RemoteResource extends Resource {
constructor(url) {
super("remote", url);
}
toModel() {
return Object.assign(Object.assign({}, super.toModel()), { headers: this.headers });
}
}
export class Base64Resource extends Resource {
constructor(content) {

View File

@ -25,9 +25,18 @@ export class LocalResource extends Resource {
}
export class RemoteResource extends Resource {
headers?: Record<string, string>
constructor(url: string) {
super("remote", url)
}
toModel() {
return {
...super.toModel(),
headers: this.headers
}
}
}
export class Base64Resource extends Resource {