Skip to content

Commit

Permalink
chore: restore alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Jul 17, 2024
1 parent 832c40e commit 493a45a
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 203 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/update_dependent_projects_alpha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,25 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: false
prerelease:
description: 'Prerelease'
required: false
default: 'false'

env:
LIBRARY_NAME: "gisce/powerp.js"

jobs:
update-dependents:
if: github.event.release.prerelease == true && contains(github.event.release.tag_name, '-alpha.') && !contains(github.event.release.tag_name, '-rc.')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- project: "gisce/webclient"
branch: "alpha"
steps:
- name: Set environment variables and check condition
run: |
TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag_name }}"
PRERELEASE="${{ github.event.release.prerelease || github.event.inputs.prerelease }}"
if [ "$PRERELEASE" == "true" ] && [[ "$TAG_NAME" != *'-rc.'* ]] && [[ "$TAG_NAME" == *'-alpha.'* ]]; then
SHOULD_RUN="true"
else
SHOULD_RUN="false"
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
echo "SHOULD_RUN=$SHOULD_RUN" >> $GITHUB_ENV
- name: Check Prerelease and Tag Version
if: env.SHOULD_RUN == 'true'
run: echo "Running update for tag ${{ env.TAG_NAME }}"
- name: Call Reusable Workflow for each project
if: env.SHOULD_RUN == 'true'
uses: gisce/create-update-version-pr@v0.0.5
with:
dependentProject: ${{ matrix.project }}
tagName: ${{ env.TAG_NAME }}
tagName: ${{ github.event.release.tag_name }}
dependentProjectBranch: ${{ matrix.branch }}
libraryName: ${{ env.LIBRARY_NAME }}
githubToken: ${{ secrets.GH_PAT }}
27 changes: 2 additions & 25 deletions .github/workflows/update_dependent_projects_v2-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,25 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: false
prerelease:
description: 'Prerelease'
required: false
default: 'false'

env:
LIBRARY_NAME: "gisce/powerp.js"

jobs:
update-dependents:
if: github.event.release.prerelease == true && !contains(github.event.release.tag_name, '-alpha.') && contains(github.event.release.tag_name, '-rc.')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- project: "gisce/webclient"
branch: "v2-develop"
steps:
- name: Set environment variables and check condition
run: |
TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag_name }}"
PRERELEASE="${{ github.event.release.prerelease || github.event.inputs.prerelease }}"
if [ "$PRERELEASE" == "true" ] && [[ "$TAG_NAME" == *'-rc.'* ]] && [[ "$TAG_NAME" != *'-alpha.'* ]]; then
SHOULD_RUN="true"
else
SHOULD_RUN="false"
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
echo "SHOULD_RUN=$SHOULD_RUN" >> $GITHUB_ENV
- name: Check Prerelease and Tag Version
if: env.SHOULD_RUN == 'true'
run: echo "Running update for tag ${{ env.TAG_NAME }}"
- name: Call Reusable Workflow for each project
if: env.SHOULD_RUN == 'true'
uses: gisce/create-update-version-pr@v0.0.5
with:
dependentProject: ${{ matrix.project }}
tagName: ${{ env.TAG_NAME }}
tagName: ${{ github.event.release.tag_name }}
dependentProjectBranch: ${{ matrix.branch }}
libraryName: ${{ env.LIBRARY_NAME }}
githubToken: ${{ secrets.GH_PAT }}
29 changes: 3 additions & 26 deletions .github/workflows/update_dependent_projects_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,25 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: false
prerelease:
description: 'Prerelease'
required: false
default: 'false'

env:
LIBRARY_NAME: "gisce/powerp.js"

jobs:
update-dependents:
if: github.event.release.prerelease == false && contains(github.event.release.tag_name, 'v2')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- project: "gisce/webclient"
branch: "v2"
steps:
- name: Set environment variables and check condition
run: |
TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag_name }}"
PRERELEASE="${{ github.event.release.prerelease || github.event.inputs.prerelease }}"
if [ "$PRERELEASE" != "true" ] && [[ "$TAG_NAME" == *'v2'* ]]; then
SHOULD_RUN="true"
else
SHOULD_RUN="false"
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
echo "SHOULD_RUN=$SHOULD_RUN" >> $GITHUB_ENV
- name: Check Prerelease and Tag Version
if: env.SHOULD_RUN == 'true'
run: echo "Running update for tag ${{ env.TAG_NAME }}"
- name: Call Reusable Workflow for each project
if: env.SHOULD_RUN == 'true'
uses: gisce/create-update-version-pr@v0.0.5
with:
dependentProject: ${{ matrix.project }}
tagName: ${{ env.TAG_NAME }}
tagName: ${{ github.event.release.tag_name }}
dependentProjectBranch: ${{ matrix.branch }}
libraryName: ${{ env.LIBRARY_NAME }}
githubToken: ${{ secrets.GH_PAT }}
githubToken: ${{ secrets.GH_PAT }}
42 changes: 10 additions & 32 deletions lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,15 @@ export class Client {

// console.debug(`Sending ${options.payload} to ${host}/${service}`);

if (!host) {
throw new Error("You must set a host first");
}

try {
const response = await this.getAxiosInstance().post(
`${host}/${service}`,
`${host!}/${service}`,
data.payload,
{
headers: getDefaultHeaders(this.clientHeader),
headers: {
"Content-Type": "application/json",
"X-GISCE-Client": this.clientHeader,
},
...options,
},
);
Expand All @@ -79,22 +78,12 @@ export class Client {
}
return response.data;
} catch (e) {
if (e.name === "CanceledError" && process.env.NODE_ENV !== "production") {
console.warn(
`CANCELED request to ${host}/${service}: ${JSON.stringify(
e,
null,
2,
)}`,
);
} else if (e.name !== "CanceledError") {
if (e?.message && e.message === "AccessDenied Token Error") {
this.onTokenAccessDenied?.(e);
}
console.error(
`Error in fetching ${host}/${service}: ${JSON.stringify(e, null, 2)}`,
);
if (e === "AccessDenied Token Error") {
this.onTokenAccessDenied?.(e);
}
console.error(
`Error in fetching ${host!}/${service}: ${JSON.stringify(e, null, 2)}`,
);
throw e;
}
}
Expand Down Expand Up @@ -296,14 +285,3 @@ export class Client {
});
}
}

function getDefaultHeaders(clientHeader?: string): Record<string, string> {
const defaultHeaders: Record<string, string> = {
"Content-Type": "application/json",
};
if (clientHeader) {
defaultHeaders["X-GISCE-Client"] = clientHeader;
}

return defaultHeaders;
}
24 changes: 24 additions & 0 deletions lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ModelExportDataOpts,
RequestOptions,
ReadForViewOpts,
ReadAggOpts,
} from "./types";
import {
createSearchPayload,
Expand All @@ -34,6 +35,7 @@ import {
createFieldsGetPayload,
createExportDataPayload,
createReadForViewPayload,
createReadAggPayload,
} from "./payloads";

export class Model {
Expand Down Expand Up @@ -426,4 +428,26 @@ export class Model {
options,
});
}

public async read_agg(
data: ReadAggOpts,
options?: RequestOptions,
): Promise<any> {
const { domain = [], aggregate_fields } = data;
const { model } = this;
const { database, token } = this.client;

const payload = createReadAggPayload({
database: database!,
token: token!,
model,
domain,
aggregate_fields,
});

return await this.client._fetch({
payload,
options,
});
}
}
14 changes: 14 additions & 0 deletions lib/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
ModelFieldsGetPayload,
ModelExportDataPayload,
ReadForViewPayload,
ReadAggPayload,
} from "./types";

export const makeLoginTokenPayload = (options: LoginTokenPayload): Payload => {
Expand Down Expand Up @@ -423,3 +424,16 @@ export const createReadForViewPayload = (
context,
];
};
export const createReadAggPayload = (options: ReadAggPayload): Payload => {
const { database, token, model, domain, aggregate_fields } = options;
return [
"execute",
database,
"token",
token,
model,
"read_agg",
domain,
aggregate_fields,
];
};
7 changes: 7 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,10 @@ export type ReadForViewOpts = {
};

export type ReadForViewPayload = Database & Token & Model & ReadForViewOpts;

export type ReadAggOpts = {
domain?: any[];
aggregate_fields: Record<string, string[]>;
};

export type ReadAggPayload = Database & Token & Model & ReadAggOpts;
Loading

0 comments on commit 493a45a

Please sign in to comment.