feat(client): add rich domain classes, helpers, and refactor GitLabClient internals
This commit is contained in:
50
ts/gitlab.classes.variable.ts
Normal file
50
ts/gitlab.classes.variable.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { IGitLabVariable, IGitLabPipelineVariable } from './gitlab.interfaces.js';
|
||||
|
||||
export class GitLabVariable {
|
||||
public readonly key: string;
|
||||
public readonly value: string;
|
||||
public readonly variableType: string;
|
||||
public readonly protected: boolean;
|
||||
public readonly masked: boolean;
|
||||
public readonly environmentScope: string;
|
||||
|
||||
constructor(raw: IGitLabVariable) {
|
||||
this.key = raw.key || '';
|
||||
this.value = raw.value || '';
|
||||
this.variableType = raw.variable_type || 'env_var';
|
||||
this.protected = raw.protected ?? false;
|
||||
this.masked = raw.masked ?? false;
|
||||
this.environmentScope = raw.environment_scope || '*';
|
||||
}
|
||||
|
||||
toJSON(): IGitLabVariable {
|
||||
return {
|
||||
key: this.key,
|
||||
value: this.value,
|
||||
variable_type: this.variableType,
|
||||
protected: this.protected,
|
||||
masked: this.masked,
|
||||
environment_scope: this.environmentScope,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class GitLabPipelineVariable {
|
||||
public readonly key: string;
|
||||
public readonly value: string;
|
||||
public readonly variableType: string;
|
||||
|
||||
constructor(raw: IGitLabPipelineVariable) {
|
||||
this.key = raw.key || '';
|
||||
this.value = raw.value || '';
|
||||
this.variableType = raw.variable_type || 'env_var';
|
||||
}
|
||||
|
||||
toJSON(): IGitLabPipelineVariable {
|
||||
return {
|
||||
key: this.key,
|
||||
value: this.value,
|
||||
variable_type: this.variableType,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user