namazu-ts 0.1.0

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 (59) hide show
  1. package/.prettierignore +4 -0
  2. package/.prettierrc +6 -0
  3. package/README.md +13 -0
  4. package/dist/browser/index.css +793 -0
  5. package/dist/browser/index.js +29829 -0
  6. package/dist/client.d.ts +41 -0
  7. package/dist/index.d.ts +5 -0
  8. package/dist/maputils.d.ts +13 -0
  9. package/dist/node/index.css +788 -0
  10. package/dist/node/index.js +42188 -0
  11. package/dist/sismomap.d.ts +21 -0
  12. package/dist/types.d.ts +197 -0
  13. package/dist/utils.d.ts +4 -0
  14. package/docs/.nojekyll +1 -0
  15. package/docs/assets/hierarchy.js +1 -0
  16. package/docs/assets/highlight.css +71 -0
  17. package/docs/assets/icons.js +18 -0
  18. package/docs/assets/icons.svg +1 -0
  19. package/docs/assets/main.js +60 -0
  20. package/docs/assets/navigation.js +1 -0
  21. package/docs/assets/search.js +1 -0
  22. package/docs/assets/style.css +1633 -0
  23. package/docs/classes/Client.html +31 -0
  24. package/docs/classes/LngLatBounds.html +120 -0
  25. package/docs/classes/SismoMap.html +12 -0
  26. package/docs/functions/EventToEventGeoJSON.html +1 -0
  27. package/docs/functions/createMap.html +6 -0
  28. package/docs/hierarchy.html +1 -0
  29. package/docs/index.html +9 -0
  30. package/docs/modules.html +1 -0
  31. package/docs/types/Answer.html +5 -0
  32. package/docs/types/City.html +7 -0
  33. package/docs/types/CleanedFDSNQueryOptions.html +1 -0
  34. package/docs/types/EventFeature.html +5 -0
  35. package/docs/types/EventGeoJSON.html +3 -0
  36. package/docs/types/EventGeoJSONProperties.html +11 -0
  37. package/docs/types/EventGeojsonDescriptionProperty.html +3 -0
  38. package/docs/types/FDSNQueryOptions.html +29 -0
  39. package/docs/types/Form.html +7 -0
  40. package/docs/types/Magnitude.html +16 -0
  41. package/docs/types/Origin.html +27 -0
  42. package/docs/types/Question.html +12 -0
  43. package/docs/types/QuestionChoice.html +5 -0
  44. package/docs/types/QuestionCondition.html +1 -0
  45. package/docs/types/QuestionGroup.html +3 -0
  46. package/docs/types/SisEvent.html +12 -0
  47. package/docs/types/Street.html +4 -0
  48. package/docs/types/Survey.html +5 -0
  49. package/docs/types/Testimony.html +17 -0
  50. package/docs/variables/eventTypes.html +1 -0
  51. package/docs/variables/mapLayers.html +1 -0
  52. package/package.json +54 -0
  53. package/src/client.ts +552 -0
  54. package/src/index.ts +5 -0
  55. package/src/maputils.ts +116 -0
  56. package/src/sismomap.ts +108 -0
  57. package/src/types.ts +237 -0
  58. package/src/utils.ts +20 -0
  59. package/typedoc.json +1 -0
@@ -0,0 +1,41 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { CleanedFDSNQueryOptions, FDSNQueryOptions } from './types';
3
+ import { Result } from 'neverthrow';
4
+ import { Form, Question, Survey, City, Testimony, QuestionChoice, Answer, EventGeoJSON, SisEvent as NamazuEvent } from './types';
5
+ export declare class Client {
6
+ private axiosInstance;
7
+ constructor(baseUrl: string);
8
+ setBaseUrl(baseUrl: string): void;
9
+ apiCall<Type>(apiRoute: AxiosRequestConfig): Promise<Type>;
10
+ apiCall<Type>(apiRoute: string, method?: string): Promise<Type>;
11
+ fetchForm(id: number): Promise<Form>;
12
+ getQuestion(form: Form, question_id: number): Question | undefined;
13
+ getChoice(question: Question, choice_id: number): QuestionChoice | undefined;
14
+ createIndividualTestimony(eventPublicID: string, email: string): Promise<Testimony>;
15
+ createCityTestimony(eventPublicID: string, cityID: number, administrativeCodeType: string, administrativeCode: string, author: string, email: string, organization: string): Promise<Testimony>;
16
+ updateAnswer(key: string, questionID: number, choices: number[], value: string): Promise<Answer[]>;
17
+ updateTestimonyLocation(key: string, longitude: number, latitude: number): Promise<Testimony | void>;
18
+ setTestimonyDone(key: string, testimonyDone: boolean): Promise<Testimony | void>;
19
+ fetchEvent(eventPublicID: string): Promise<NamazuEvent>;
20
+ fetchEvents(startDate: Date, endDate: Date): Promise<EventGeoJSON>;
21
+ fetchSurvey(surveyKey: string): Promise<Survey>;
22
+ fetchTestimony(key: string): Promise<Testimony>;
23
+ fetchAnswers(key: string): Promise<Answer[]>;
24
+ fetchCitiesByMatch(match: string): Promise<City[]>;
25
+ fetchCitiesByAdministrativeCode(administrative_code_type: string, administrative_code: string): Promise<City[]>;
26
+ formatMagnitude(magnitude: number): string;
27
+ getCurrentChoices(question_id: number, answers: Answer[]): number[];
28
+ getCurrentValue(question_id: number, answers: Answer[]): string | undefined;
29
+ isConditionsSatisfied(question: Question, answers: Answer[] | undefined): boolean;
30
+ getLastAnsweredQuestion(form: Form, answers: Answer[]): Question | undefined;
31
+ getPreviousQuestion(form: Form, answers: Answer[], currentQuestion?: Question): Question | undefined;
32
+ getNextQuestion(form: Form, answers: Answer[], currentQuestion?: Question): Question | undefined;
33
+ formatDateFR(dateString: Date): string;
34
+ translateEventType(eventType: string): string;
35
+ buildQuery(url: string, options: CleanedFDSNQueryOptions): AxiosRequestConfig;
36
+ /**
37
+ * <!> IF YOU WANT TO CAST AS NAMAZU TYPE LATER, SET format:'json'
38
+ */
39
+ cleanQuery(options: FDSNQueryOptions): Result<CleanedFDSNQueryOptions, Error>;
40
+ }
41
+ export declare const eventTypes: Map<string, string>;
@@ -0,0 +1,5 @@
1
+ export { LngLatBounds } from 'maplibre-gl';
2
+ export * from './maputils';
3
+ export * from './client';
4
+ export * from './sismomap';
5
+ export * from './types';
@@ -0,0 +1,13 @@
1
+ import maplibregl from 'maplibre-gl';
2
+ import 'maplibre-gl/dist/maplibre-gl.css';
3
+ import { SismoMap } from './sismomap';
4
+ import { SisEvent, EventGeoJSON } from './types';
5
+ /**
6
+ * Map creating function,
7
+ * @param name Name of the map, doesn't influence the behaviour
8
+ * @param containerID ID of the container that the map will be in
9
+ * @param bounds Optional bounds of the view when creating the map if absent, defaults to 0,0
10
+ * @return Promise<SismoMap> Promise that will be resolved when the map is created (bound zoom might not be over, but it's not a problem, zooms adjusts in real time to other functions)
11
+ */
12
+ export declare function createMap(name: string, containerID: string, lang: string, bounds?: maplibregl.LngLatBounds): Promise<SismoMap>;
13
+ export declare function EventToEventGeoJSON(e: SisEvent): EventGeoJSON;