-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelldoneCore.ts
More file actions
95 lines (77 loc) · 3.79 KB
/
SelldoneCore.ts
File metadata and controls
95 lines (77 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Copyright (c) 2023. Selldone® Business OS™
*
* Author: M.Pajuhaan
* Web: https://selldone.com
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
*
* All rights reserved. In the weave of time, where traditions and innovations intermingle, this content was crafted.
* From the essence of thought, through the corridors of creativity, each word, and sentiment has been molded.
* Not just to exist, but to inspire. Like an artist's stroke or a sculptor's chisel, every nuance is deliberate.
* Our journey is not just about reaching a destination, but about creating a masterpiece.
* Tread carefully, for you're treading on dreams.
*/
import {Gapi} from "./gapi/Gapi";
import {GAPI} from "./server/GAPI";
import {SetupService} from "./server/SetupService";
import "./utils/console/ConsoleStyle";
import {CDN} from "./server/CDN";
import {URLS} from "./server/URLS";
import Cookie from "./utils/cookie/cookie";
import axios from "axios";
const SDK_VERSION = "0.04";
//█████████████████████████████████████████████████████████████
//―――――――――――――― Global Types ―――――――――――――――
//█████████████████████████████████████████████████████████████
// Extend the Window interface to recognize the properties you add to the global window object.
declare global {
interface Window {
axios: any;
CDN: CDN;
URLS: URLS;
// APIs
GAPI: GAPI;
// Selldone Core
$selldone: {
gapi: Gapi;
};
$cookies: typeof Cookie;
}
}
//█████████████████████████████████████████████████████████████
//――――――――――― Selldone® Storefront SDK ―――――――――――
//█████████████████████████████████████████████████████████████
export class SelldoneCore {
static Setup({ i18n = null }: { i18n?: any } = {}): void {
console.log(`Selldone® Core: V${SDK_VERSION}`);
if (i18n) {
window.$i18n_global = i18n;
}
//――――――――――――――――――――――――― Axios ―――――――――――――――――――――――――
window.axios = axios;
// 🞧 Header: CORS
window.axios.defaults.headers.common["Access-Control-Allow-Origin"] =
SetupService.MainServiceUrl();
window.axios.defaults.headers.common["Access-Control-Allow-Headers"] =
"Origin, X-Requested-With, Content-Type, Accept";
// Set CSRF token:
const token = SetupService.GetMetaValue("csrf-token");
if (token) {
// 🞧 Header: CSRF
window.axios.defaults.headers.common["X-CSRF-TOKEN"] = token;
} else {
console.warn("CSRF token not found!");
}
//――――――――――――――――――――――――― Initialize Resources Origin ―――――――――――――――――――――――――
window.CDN = new CDN();
window.URLS = new URLS();
// Define API repositories:
window.GAPI = new GAPI();
//――――――――――――――――――――――――― Create Instance ―――――――――――――――――――――――――
window.$selldone = {
gapi: new Gapi(),
};
// Register $cookies to window
window.$cookies = Cookie;
}
}