sdc_client 0.58.6 → 0.158.1

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.
Files changed (39) hide show
  1. package/.github/workflows/node.js.yml +2 -2
  2. package/.idea/inspectionProfiles/Project_Default.xml +17 -0
  3. package/.idea/workspace.xml +122 -23
  4. package/.readthedocs.yaml +13 -0
  5. package/dist/index.js +70 -51
  6. package/dist/ugly.index.js +1 -1
  7. package/docs/api-reference.rst +225 -0
  8. package/docs/conf.py +11 -0
  9. package/docs/controllers.rst +228 -0
  10. package/docs/events-and-dom.rst +120 -0
  11. package/docs/getting-started.rst +143 -0
  12. package/docs/index.rst +22 -0
  13. package/docs/models.rst +351 -0
  14. package/docs/overview.rst +66 -0
  15. package/docs/requirements.txt +1 -0
  16. package/eslint.config.js +60 -0
  17. package/gulp/gulp.jsx +15 -13
  18. package/package.json +13 -3
  19. package/src/index.js +44 -11
  20. package/src/simpleDomControl/AbstractSDC.js +287 -286
  21. package/src/simpleDomControl/sdc_controller.js +157 -132
  22. package/src/simpleDomControl/sdc_dom_events.js +99 -88
  23. package/src/simpleDomControl/sdc_events.js +39 -40
  24. package/src/simpleDomControl/sdc_main.js +88 -67
  25. package/src/simpleDomControl/sdc_model.js +1513 -0
  26. package/src/simpleDomControl/sdc_params.js +44 -29
  27. package/src/simpleDomControl/sdc_server_call.js +153 -154
  28. package/src/simpleDomControl/sdc_socket.js +8 -829
  29. package/src/simpleDomControl/sdc_test_utils.js +77 -80
  30. package/src/simpleDomControl/sdc_utils.js +295 -176
  31. package/src/simpleDomControl/sdc_view.js +245 -177
  32. package/test/model.test.js +332 -0
  33. package/test/models/Author.js +145 -0
  34. package/test/models/Book.js +112 -0
  35. package/test/models/BookContent.js +114 -0
  36. package/test/models/SdcUser.js +75 -0
  37. package/test/models/src.js +8 -0
  38. package/test/sdc_model_dates.ai.test.js +57 -0
  39. package/test/sdc_server_call.ai.test.js +267 -0
@@ -1,52 +1,49 @@
1
1
  /**
2
2
  * @jest-environment jsdom
3
3
  */
4
- ;
4
+ import { app } from "./sdc_main.js";
5
5
 
6
- import {app} from './sdc_main.js'
7
-
8
- let spy = [], _originAjax;
6
+ let spy = [],
7
+ _originAjax;
9
8
 
10
9
  function setDefaults() {
11
- if (!jest) throw new Error("JEST is not defined");
12
- if (spy.length === 0) {
13
- _originAjax = $.ajax.bind($);
14
-
15
- spy.push(jest.spyOn(
16
- $,
17
- 'ajax'
18
- ));
19
- spy[0].mockImplementation(function (a) {
20
- return _originAjax(a).then((html) => {
21
- return html;
22
- }).catch((html) => {
23
- return html;
24
- });
10
+ if (!jest) throw new Error("JEST is not defined");
11
+ if (spy.length === 0) {
12
+ _originAjax = $.ajax.bind($);
13
+
14
+ spy.push(jest.spyOn($, "ajax"));
15
+ spy[0].mockImplementation(function (a) {
16
+ return _originAjax(a)
17
+ .then((html) => {
18
+ return html;
19
+ })
20
+ .catch((html) => {
21
+ return html;
25
22
  });
26
- }
23
+ });
24
+ }
27
25
  }
28
26
 
29
-
30
27
  function getCookie(name) {
31
- let cookieValue = null;
32
- if (document.cookie && document.cookie !== '') {
33
- const cookies = document.cookie.split(';');
34
- for (let i = 0; i < cookies.length; i++) {
35
- const cookie = cookies[i].trim();
36
- // Does this cookie string begin with the name we want?
37
- if (cookie.substring(0, name.length + 1) === (name + '=')) {
38
- return decodeURIComponent(cookie.substring(name.length + 1));
39
- }
40
- }
28
+ let cookieValue = null;
29
+ if (document.cookie && document.cookie !== "") {
30
+ const cookies = document.cookie.split(";");
31
+ for (let i = 0; i < cookies.length; i++) {
32
+ const cookie = cookies[i].trim();
33
+ // Does this cookie string begin with the name we want?
34
+ if (cookie.substring(0, name.length + 1) === name + "=") {
35
+ return decodeURIComponent(cookie.substring(name.length + 1));
36
+ }
41
37
  }
42
- return '';
38
+ }
39
+ return "";
43
40
  }
44
41
 
45
42
  /**
46
43
  * Returns the CSRF token
47
44
  */
48
45
  export function getCsrfToken() {
49
- return getCookie('csrftoken');
46
+ return getCookie("csrftoken");
50
47
  }
51
48
 
52
49
  /**
@@ -56,36 +53,32 @@ export function getCsrfToken() {
56
53
  * @returns {Promise<Array<{AbstractSDC}>>}
57
54
  */
58
55
  export async function controllerFromTestHtml(html, afterLifecycle = null) {
59
- setDefaults();
60
- const $body = $('body');
61
- app.updateJquery();
62
- $body.safeEmpty().append(html);
63
- app._isInit = false;
64
- app.cleanCache();
65
- await app.init_sdc();
66
-
67
-
68
- let children = app.rootController.iterateAllChildren();
69
-
70
- if (!afterLifecycle) {
71
- return children
72
- }
73
-
74
- const origenRefresh = children[0].onRefresh;
75
-
76
- const refreshSpy = jest.spyOn(
77
- children[0],
78
- 'onRefresh'
79
- );
80
-
81
- return new Promise((resolve) => {
82
- refreshSpy.mockImplementation(function () {
83
- refreshSpy.mockRestore();
84
- const res = origenRefresh.apply(children[0], arguments);
85
- resolve(children);
86
- return res;
87
- });
56
+ setDefaults();
57
+ const $body = $("body");
58
+ app.updateJquery();
59
+ $body.safeEmpty().append(html);
60
+ app._isInit = false;
61
+ app.cleanCache();
62
+ await app.init_sdc();
63
+
64
+ let children = app.rootController.iterateAllChildren();
65
+
66
+ if (!afterLifecycle) {
67
+ return children;
68
+ }
69
+
70
+ const origenRefresh = children[0].onRefresh;
71
+
72
+ const refreshSpy = jest.spyOn(children[0], "onRefresh");
73
+
74
+ return new Promise((resolve) => {
75
+ refreshSpy.mockImplementation(function () {
76
+ refreshSpy.mockRestore();
77
+ const res = origenRefresh.apply(children[0], arguments);
78
+ resolve(children);
79
+ return res;
88
80
  });
81
+ });
89
82
  }
90
83
 
91
84
  /**
@@ -96,22 +89,26 @@ export async function controllerFromTestHtml(html, afterLifecycle = null) {
96
89
  * @param origen_html{string} HTML: Mocked content of the content in your target HTML container.
97
90
  * @returns {Promise<{AbstractSDC}>}
98
91
  */
99
- export async function get_controller(tag_name, init_arguments = {}, origen_html = '') {
100
- setDefaults();
101
- const $body = $('body');
102
- app.updateJquery();
103
-
104
- $body.safeEmpty();
105
-
106
- const $controller = $(`<${tag_name}>${origen_html}</${tag_name}>`);
107
- for (const [key, value] of Object.entries(init_arguments)) {
108
- $controller.data(key, value);
109
- }
110
- const $divContainer = $('<div></div>').append($controller);
111
-
112
- $body.append($divContainer);
113
- app._isInit = false;
114
- app.cleanCache();
115
- await app.init_sdc();
116
- return app.getController($controller);
117
- }
92
+ export async function get_controller(
93
+ tag_name,
94
+ init_arguments = {},
95
+ origen_html = "",
96
+ ) {
97
+ setDefaults();
98
+ const $body = $("body");
99
+ app.updateJquery();
100
+
101
+ $body.safeEmpty();
102
+
103
+ const $controller = $(`<${tag_name}>${origen_html}</${tag_name}>`);
104
+ for (const [key, value] of Object.entries(init_arguments)) {
105
+ $controller.data(key, value);
106
+ }
107
+ const $divContainer = $("<div></div>").append($controller);
108
+
109
+ $body.append($divContainer);
110
+ app._isInit = false;
111
+ app.cleanCache();
112
+ await app.init_sdc();
113
+ return app.getController($controller);
114
+ }